src/FileSignatureUtils.php
public static function hasSignature($string, $signature)
    {
        if (ctype_xdigit($signature) === false) {
            throw new \InvalidArgumentException(sprintf('Invalid HEX signature provided: %s', $signature));
        }
        $signatureChars = str_split($signature, 2);
        $hexChars = array_map(
            function ($val) {
                return strtoupper(bin2hex($val));
            },
            str_split(substr($string, 0, count($signatureChars)))
        );

        return $hexChars === $signatureChars;
    }
public static function hasSignature($string, $signature)
    {
        if (ctype_xdigit($signature) === false) {
            throw new \InvalidArgumentException(sprintf('Invalid HEX signature provided: %s', $signature));
        }
        $signatureChars = str_split($signature, 2);
        $hexChars = array_map(
            function ($val) {
                return strtoupper(bin2hex($val));
            },
            str_split(substr($string, 0, count($signatureChars)))
        );

        return $hexChars === $signatureChars;
    }
public static function hasSignature ( $ string , $ signature ) { if ( ctype_xdigit ( $ signature ) === false ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HEX signature provided: %s' , $ signature ) ) ; } $ signatureChars = str_split ( $ signature , 2 ) ; $ hexChars = array_map ( function ( $ val ) { return strtoupper ( bin2hex ( $ val ) ) ; } , str_split ( substr ( $ string , 0 , count ( $ signatureChars ) ) ) ) ; return $ hexChars === $ signatureChars ; }
Determine whether the given string contains one of the registered signatures

@param string $string    the string data to check
@param string $signature the hex signature

@throws \InvalidArgumentException

@return bool
Determine whether the given string contains one of the registered signatures