| 1 | <?php |
||
| 8 | class FileSignatureUtils |
||
| 9 | { |
||
| 10 | const PNG = '89504E470D0A1A0A'; |
||
| 11 | const JPG = 'FFD8FFE0'; |
||
| 12 | const PDF = '25504446'; |
||
| 13 | const GIF = '47494638'; |
||
| 14 | const BMP = '424D'; |
||
| 15 | const XML = '3C3F786D6C'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Determine whether the given string contains one of the registered signatures |
||
| 19 | * |
||
| 20 | * @param string $string the string data to check |
||
| 21 | * @param string $signature the hex signature |
||
| 22 | * |
||
| 23 | * @throws \InvalidArgumentException |
||
| 24 | * |
||
| 25 | * @return bool |
||
| 26 | */ |
||
| 27 | 3 | public static function hasSignature($string, $signature) |
|
| 42 | } |
||
| 43 |