ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
PendingRegistrationId.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Data\UUID\Factory as UUIDFactory;
24
25final readonly class PendingRegistrationId
26{
27 private string $uuid;
28
29 public function __construct(string $uuid)
30 {
31 if (mb_strlen($uuid) !== 36) {
32 throw new \InvalidArgumentException('Registration UUID must be 32 characters (UUIDv4).');
33 }
34
35 $this->uuid = $uuid;
36 }
37
38 public static function create(): self
39 {
40 return new self((new UUIDFactory())->uuid4AsString());
41 }
42
43 public function equals(self $other): bool
44 {
45 return hash_equals($this->uuid, $other->uuid);
46 }
47
48 public function toString(): string
49 {
50 return $this->uuid;
51 }
52
53 public function __toString(): string
54 {
55 return $this->toString();
56 }
57}