| Total Complexity | 4 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 6 | class NonceGenerator { |
||
| 7 | |||
| 8 | private array $nonces = []; |
||
| 9 | |||
| 10 | protected function _generateNonce(string $name, ?int $value = null): string { |
||
| 11 | $bytes = \random_bytes((int) ($value ?? 32)); |
||
| 12 | $nonce = \base64_encode($bytes); |
||
| 13 | if (! URequest::isAjax()) { |
||
| 14 | $this->onNonce($name, $nonce); |
||
| 15 | } |
||
| 16 | return $nonce; |
||
| 17 | } |
||
| 18 | |||
| 19 | public function getNonce(string $name) { |
||
| 21 | } |
||
| 22 | |||
| 23 | function onNonce(string $name, string $value) {} |
||
| 26 |