Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
27 | 3 | public static function hasSignature($string, $signature) |
|
28 | { |
||
29 | 3 | if (ctype_xdigit($signature) === false) { |
|
30 | 1 | throw new \InvalidArgumentException(sprintf('Invalid HEX signature provided: %s', $signature)); |
|
31 | } |
||
32 | 2 | $signatureChars = str_split($signature, 2); |
|
33 | 2 | $hexChars = array_map( |
|
34 | 2 | function ($val) { |
|
35 | 2 | return strtoupper(bin2hex($val)); |
|
36 | 2 | }, |
|
37 | 2 | str_split(substr($string, 0, count($signatureChars))) |
|
38 | 2 | ); |
|
39 | |||
40 | 2 | return $hexChars === $signatureChars; |
|
41 | } |
||
42 | } |
||
43 |