for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Kepawni\Twilted\Basic;
use Kepawni\Twilted\EntityIdentifier;
use Kepawni\Twilted\Foldable;
use Ramsey\Uuid\Exception\InvalidUuidStringException;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
class AggregateUuid implements EntityIdentifier
{
/** @var UuidInterface */
private $uuid;
private function __construct(UuidInterface $uuid)
$this->uuid = $uuid;
}
/**
* @return static
*/
public static function createRandom(): self
return new static(Uuid::uuid4());
* @param string $leaflet The compact representation of this instance.
*
* @return static The instance reconstituted from unfolding the leaflet.
* @throws InvalidUuidStringException When the leaflet is not a valid UUID string.
public static function unfold(string $leaflet): Foldable
return new static(Uuid::fromString($leaflet));
* @param mixed $other Another value to test.
* @return bool True when the other value is equal to this instance.
public function equals($other): bool
return $other instanceof static && $this->uuid->equals($other->uuid);
* @return string A compact representation (like a leaflet) of this instance.
public function fold(): string
return $this->uuid->toString();