A domain identifier is a value object and bound to MsgPhp\Domain\DomainId. Its purpose is to utilize a primitive
identifier value, usually used to identity an entity with.
Tells if an identifier value is nil, thus is considered empty/unknown.
Tells if an identifier strictly equals another identifier.
Returns the identifier its primitive string value.
A generic identifier compatible with any string value.
<?php
use MsgPhp\Domain\GenericDomainId;
// SETUP
$id = new GenericDomainId('1');
$id = GenericDomainId::fromInt(1);
$nilId = new GenericDomainId();
// USAGE
$id->isNil(); // false
$nilId->isNil(); // true
$id->toString(); // "1"
$nilId->toString(); // ""
$id->equals(new GenericDomainId('1')); // true
$id->equals('1'); // false
$id->equals(new GenericDomainId('2')); // false
$id->equals(new GenericDomainId()); // falseA decorating identifier to built custom/concrete identifiers upon.
<?php
use MsgPhp\Domain\AbstractDomainId;
// SETUP
class MyDomainId extends AbstractDomainId
{
}
class MyOtherDomainId extends AbstractDomainId
{
}
$id = MyDomainId::fromInt(1);
$otherId = MyOtherDomainId::fromInt(1);
// USAGE
$id->equals($otherId); // false- Unique Identifier (UUID, ULID, etc.)