| Total Complexity | 3 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | final class Hash implements Verifier |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * The hash context. |
||
| 27 | * |
||
| 28 | * @var resource |
||
| 29 | */ |
||
| 30 | private $context; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | public function __construct(string $algorithm, string $path) |
||
| 36 | { |
||
| 37 | $algorithm = strtolower( |
||
| 38 | preg_replace( |
||
| 39 | '/[^A-Za-z0-9]+/', |
||
| 40 | '', |
||
| 41 | $algorithm |
||
| 42 | ) |
||
| 43 | ); |
||
| 44 | |||
| 45 | Assertion::inArray( |
||
| 46 | $algorithm, |
||
| 47 | hash_algos(), |
||
| 48 | 'Expected %s to be a known algorithm: "' |
||
| 49 | .implode('", "', hash_algos()) |
||
| 50 | .'"' |
||
| 51 | ); |
||
| 52 | |||
| 53 | $this->context = hash_init($algorithm); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | public function update(string $data): void |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | */ |
||
| 69 | public function verify(string $signature): bool |
||
| 72 | } |
||
| 73 | } |
||
| 74 |