ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PasswordAssistanceHash.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23final class PasswordAssistanceHash implements \Stringable
24{
25 private const HASH_LENGTH_IN_BYTES = 64;
26
27 public function __construct(
28 private readonly string $hash
29 ) {
30 if (strlen($hash) !== self::HASH_LENGTH_IN_BYTES) {
31 throw new \InvalidArgumentException(sprintf('The hash must be %s bytes long.', self::HASH_LENGTH_IN_BYTES));
32 }
33 }
34
35 public function value(): string
36 {
37 return $this->hash;
38 }
39
40 public function __toString(): string
41 {
42 return $this->value();
43 }
44}