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