Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function checksum(string $path, Config $config): string |
||
20 | { |
||
21 | $algo = $config->get('checksum_algo', 'md5'); |
||
22 | $contents = $this->read($path); |
||
23 | error_clear_last(); |
||
24 | $checksum = @hash($algo, $contents); |
||
25 | |||
26 | if ($checksum === false) { |
||
27 | throw new UnableToProvideChecksum(error_get_last()['message'] ?? '', $path); |
||
28 | } |
||
29 | |||
30 | return $checksum; |
||
31 | } |
||
33 |