| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class CsrfToken { |
||
| 14 | private $name; |
||
| 15 | private $value; |
||
| 16 | |||
| 17 | public function __construct($size = 32) { |
||
| 18 | $this->name = $this->generate ( $size ); |
||
| 19 | $this->value = $this->generate ( $size ); |
||
| 20 | } |
||
| 21 | |||
| 22 | private function generate($size): string { |
||
| 23 | $bytes = \random_bytes ( $size ); |
||
| 24 | return \rtrim ( \strtr ( \base64_encode ( $bytes ), '+/', '-_' ), '=' ); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | public function getName() { |
||
| 32 | return $this->name; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | public function getValue() { |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 |