for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* event-sourcing (https://github.com/phpgears/event-sourcing).
* Event Sourcing base.
*
* @license MIT
* @link https://github.com/phpgears/event-sourcing
* @author Julián Gutiérrez <[email protected]>
*/
declare(strict_types=1);
namespace Gears\EventSourcing\Aggregate;
use Gears\EventSourcing\Aggregate\Exception\AggregateException;
final class AggregateVersion
{
/**
* @var int
private $value;
* Version constructor.
* @param int $value
public function __construct(int $value)
if ($value < 0) {
throw new AggregateException(\sprintf('Version value should be higher than 0, %s given', $value));
}
$this->value = $value;
* Get version value.
* @return int
public function getValue(): int
return $this->value;
* Check equality.
* @param self $version
$version
\self
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
* @return bool
public function isEqualTo(self $version): bool
return $this->value === $version->getValue();
* Get next version.
* @return self
public function getNext(): self
$clone = clone $this;
$clone->value = $this->value + 1;
return $clone;
* Get previous version.
* @return AggregateVersion
public function getPrevious(): self
$clone->value = $this->value - 1;
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.