Skip to content

Instantly share code, notes, and snippets.

@morrislaptop
Last active June 12, 2021 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morrislaptop/19cd5b6821969a2c148aac13c3675c33 to your computer and use it in GitHub Desktop.
Save morrislaptop/19cd5b6821969a2c148aac13c3675c33 to your computer and use it in GitHub Desktop.
<?php
class PostAggregateRoot
{
public function publishPost(DateTime $when) {
$this->recordThat(new PostPublishScheduled($when));
if ($when < now()) {
$this->recordThat(new PostPublished());
}
return $this;
}
public function publishPostNow()
$this->recordThat(new PostPublished());
return $this;
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment