for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Cqrs package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Cqrs;
use Rhumsaa\Uuid\Uuid;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/18/15
class UuidIdentifier implements IdentifierInterface
{
* @var Uuid
protected $value;
* Constructor.
* @param Uuid $uuid
public function __construct(Uuid $uuid)
$this->value = $uuid;
}
* {@inheritdoc}
public static function generate()
return new static(Uuid::uuid4());
* @return static
public static function fromString($id)
if (null === $id) {
return null;
return new static(Uuid::fromString($id));
public function equals(IdentifierInterface $identifier)
return $this->toString() === $identifier->toString();
public function toString()
return (string) $this->value;
public function __toString()
return $this->toString();