for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* aggregate (https://github.com/phpgears/aggregate).
* Aggregate base.
*
* @license MIT
* @link https://github.com/phpgears/aggregate
* @author Julián Gutiérrez <[email protected]>
*/
declare(strict_types=1);
namespace Gears\Aggregate;
use Gears\Immutability\ImmutabilityBehaviour;
/**
* Base immutable aggregate identity.
abstract class AbstractAggregateIdentity implements AggregateIdentity
{
use ImmutabilityBehaviour;
* Identity value.
* @var string
private $value;
* AbstractIdentity constructor.
* @param string $value
final protected function __construct(string $value)
$this->checkImmutability();
$this->value = $value;
}
* {@inheritdoc}
final public function isEqualTo($identity): bool
return \is_object($identity)
&& \get_class($identity) === static::class
&& $identity->getValue() === $this->getValue();
final public function getValue(): string
return $this->value;
final public function __toString(): string
final public function serialize(): string
return \serialize($this->value);
* @param mixed $serialized
final public function unserialize($serialized): void
$this->value = \unserialize($serialized, [static::class]);
final public function jsonSerialize(): string
* @return string[]
final protected function getAllowedInterfaces(): array
return [AggregateIdentity::class];