for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Domain\Aggregates;
use Domain\Identity\Identity;
use Domain\Eventing\When\ConventionBasedWhen;
/**
* @author Sebastiaan Hilbers <[email protected]>
*/
abstract class BaseAggregateRoot implements AggregateRoot
{
* Some functionality is coming from traits :)
use Reconstitution;
use EventSourced;
use ConventionBasedWhen;
* @var Identity
private $identity;
* @var int
private $version = 0;
* @param Identity $id
protected function __construct(Identity $id)
$this->identity = $id;
}
* Gets the identity
*
* @return static
public static function fromIdentity(Identity $id)
return new static($id);
* Get the identity
* @return Identity
public function getIdentity()
return $this->identity;
* Increment the aggregate's version
* @return $this
protected function bumpVersion()
$this->version++;
return $this;
* Get aggregate version
* @return int
public function getVersion()
return $this->version;