Download src/Shared/Domain/ValueObjects/Id.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Shared/Domain/ValueObjects/Id.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Shared/Domain/ValueObjects/Id.php
-
curl -L -o Id.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Shared/Domain/ValueObjects/Id.php
1.22 kB
| declare(strict_types=1); | |
| namespace Shared\Domain\ValueObjects; | |
| use Doctrine\ORM\Mapping as ORM; | |
| use JsonSerializable; | |
| use Ramsey\Uuid\Doctrine\UuidV7Generator; | |
| use Ramsey\Uuid\Exception\UnsupportedOperationException; | |
| use Ramsey\Uuid\Uuid; | |
| use Ramsey\Uuid\UuidInterface; | |
| #[ORM\Embeddable] | |
| class Id implements JsonSerializable | |
| { | |
| #[ORM\Id] | |
| #[ORM\Column(name: "id", type: "uuid_binary", unique: true)] | |
| #[ORM\GeneratedValue(strategy: "NONE")] | |
| #[ORM\CustomIdGenerator(class: UuidV7Generator::class)] | |
| private UuidInterface $value; | |
| /** | |
| * @param null|string $value | |
| * @return void | |
| * @throws UnsupportedOperationException | |
| */ | |
| public function __construct(?string $value = null) | |
| { | |
| $this->value = is_null($value) | |
| ? Uuid::uuid7() | |
| : Uuid::fromString($value); | |
| } | |
| /** @return UuidInterface */ | |
| public function getValue(): UuidInterface | |
| { | |
| return $this->value; | |
| } | |
| /** @inheritDoc */ | |
| public function jsonSerialize(): string | |
| { | |
| return $this->value->toString(); | |
| } | |
| public function equals(Id $id): bool | |
| { | |
| return $this->value->toString() === $id->getValue()->toString(); | |
| } | |
| } | |