src/Utility/FastHasher.php
public static function hash($value, string $algorithm = 'fnv1a32'): string
    {
        $type = gettype($value);

        switch ($type) {
            case 'object':
                if (Validate::isEquatable($value)) {
                    $string = sprintf('e_%s', $value->hashValue());
                } else {
                    $string = sprintf('o_%s', spl_object_hash($value));
                }
                break;
            case 'string':
                $string = sprintf('s_%s', $value);
                break;
            case 'integer':
                $string = sprintf('i_%d', $value);
                break;
            case 'double':
                $string = sprintf('f_%.14F', $value);
                break;
            case 'boolean':
                $string = sprintf('b_%d', (int) $value);
                break;
            case 'resource':
                $string = sprintf('r_%d', (int) $value);
                break;
            case 'array':
                $string = sprintf('a_%s', serialize($value));
                break;
            default:
                $string = '0';
                break;
        }

        return hash($algorithm, $string);
    }
public static function hash($value, string $algorithm = 'fnv1a32'): string
    {
        $type = gettype($value);

        switch ($type) {
            case 'object':
                if (Validate::isEquatable($value)) {
                    $string = sprintf('e_%s', $value->hashValue());
                } else {
                    $string = sprintf('o_%s', spl_object_hash($value));
                }
                break;
            case 'string':
                $string = sprintf('s_%s', $value);
                break;
            case 'integer':
                $string = sprintf('i_%d', $value);
                break;
            case 'double':
                $string = sprintf('f_%.14F', $value);
                break;
            case 'boolean':
                $string = sprintf('b_%d', (int) $value);
                break;
            case 'resource':
                $string = sprintf('r_%d', (int) $value);
                break;
            case 'array':
                $string = sprintf('a_%s', serialize($value));
                break;
            default:
                $string = '0';
                break;
        }

        return hash($algorithm, $string);
    }
public static function hash ( $ value , string $ algorithm = 'fnv1a32' ) : string { $ type = gettype ( $ value ) ; switch ( $ type ) { case 'object' : if ( Validate :: isEquatable ( $ value ) ) { $ string = sprintf ( 'e_%s' , $ value -> hashValue ( ) ) ; } else { $ string = sprintf ( 'o_%s' , spl_object_hash ( $ value ) ) ; } break ; case 'string' : $ string = sprintf ( 's_%s' , $ value ) ; break ; case 'integer' : $ string = sprintf ( 'i_%d' , $ value ) ; break ; case 'double' : $ string = sprintf ( 'f_%.14F' , $ value ) ; break ; case 'boolean' : $ string = sprintf ( 'b_%d' , ( int ) $ value ) ; break ; case 'resource' : $ string = sprintf ( 'r_%d' , ( int ) $ value ) ; break ; case 'array' : $ string = sprintf ( 'a_%s' , serialize ( $ value ) ) ; break ; default : $ string = '0' ; break ; } return hash ( $ algorithm , $ string ) ; }
Creates a string hash for a value

@param mixed  $value     The value
@param string $algorithm The hash algorithm

@return string
Creates a string hash for a value