/
AleksWork
/
diary_plants
Обзор
Документация
Войти
/
AleksWork
/
diary_plants
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Domain/ValueObject/OId.php
64 строки
1 KB
AlexeySerov
Move Currency Oid and Price to ValueObject directory
03 фев 2026, 15:45
03 фев 2026, 15:45
bd8191f
Код
Авторство
О чём код?
<?php namespace App\Domain\ValueObject; use Symfony\Component\Uid\UuidV4; use Webmozart\Assert\Assert; /** * Object identifier is a UUIDv4 identifier to be used system-wide across modules */ final readonly class OId { private UuidV4 $value; final protected function __construct( UuidV4 $value ) { $this->value = $value; } public function __toString(): string { return $this->value->toRfc4122(); } public static function fromString(string $value): static { Assert::stringNotEmpty($value); return new static(UuidV4::fromString($value)); } public static function fromBinary(string $value): static { Assert::stringNotEmpty($value); return new static(UuidV4::fromBinary($value)); } public static function next(): static { return new static(new UuidV4()); } public function isEqual(OId $anotherId): bool { return $this->value->equals($anotherId->value); } public function toBinary(): string { return $this->value->toBinary(); } public function toRfc4122(): string { return $this->value->toRfc4122(); } public function toString(): string { return $this->toRfc4122(); } }