Total Complexity | 3 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | class ConfirmationTokenGenerator |
||
27 | { |
||
28 | private $bytes_length; |
||
29 | |||
30 | public function __construct(int $bytes_length = 16) |
||
31 | { |
||
32 | if ($bytes_length < 10) { |
||
33 | throw new InvalidArgumentException('$bytes_length must be greater than 10 to be secure!'); |
||
34 | } |
||
35 | |||
36 | $this->bytes_length = $bytes_length; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Returns a truly random token with a configured length. |
||
41 | * It returns a hex encoded 16 random bytes. |
||
42 | */ |
||
43 | public function getToken(): string |
||
48 | } |
||
49 | } |
||
50 |