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