Overview

Namespaces

  • PhpCommon
    • Comparison
      • Equivalence
      • Hasher

Classes

  • DateTimeHasher
  • GenericHasher
  • IdentityHasher
  • ValueHasher
  • Overview
  • Namespace
  • Class

Class GenericHasher

Base class for implementing generic hashers.

PhpCommon\Comparison\Equivalence\GenericEquivalence implements PhpCommon\Comparison\Equivalence
Extended by PhpCommon\Comparison\Hasher\GenericHasher implements PhpCommon\Comparison\Hasher

Direct known subclasses

PhpCommon\Comparison\Hasher\IdentityHasher

Indirect known subclasses

PhpCommon\Comparison\Hasher\ValueHasher
Abstract
Namespace: PhpCommon\Comparison\Hasher
Author: Marcos Passos marcos@marcospassos.com
Located at Hasher/GenericHasher.php
Methods summary
public integer
# hash( mixed $value )

Returns a hash code for the given value.

Returns a hash code for the given value.

Parameters

$value
The value to hash.

Returns

integer
The hash code for the given value.

Throws

UnexpectedTypeException

If the type of the specified value does not match the expected type.


InvalidArgumentException

If some property of the specified value prevents it from being hashed.

Implementation of

PhpCommon\Comparison\Hasher::hash()
abstract protected integer
# hashArray( array $value )

Returns a hash code for the given array.

Returns a hash code for the given array.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentArray() method, which means that for any references $x and $y, if equivalentArray($x, $y), then hashArray($x) === hashArray($y).

Parameters

$value
The array to hash.

Returns

integer
The hash code for the given array.

Link

PHP array
abstract protected integer
# hashBoolean( boolean $value )

Returns a hash code for the given boolean value.

Returns a hash code for the given boolean value.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentBoolean() method, which means that for any references $x and $y, if equivalentBoolean($x, $y), then hashBoolean($x) === hashBoolean($y).

Parameters

$value
The boolean value to hash.

Returns

integer
The hash code for the given boolean value.

Link

PHP boolean
abstract protected integer
# hashFloat( float $value )

Returns a hash code for the given floating-point number.

Returns a hash code for the given floating-point number.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentFloat() method, which means that for any references $x and $y, if equivalentFloat($x, $y), then hashFloat($x) === hashFloat($y).

Parameters

$value
The floating-point number to hash.

Returns

integer
The hash code for the given floating-point number.

Link

PHP float
abstract protected integer
# hashInteger( integer $value )

Returns a hash code for the given integer number.

Returns a hash code for the given integer number.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentInteger() method, which means that for any references $x and $y, if equivalentInteger($x, $y), then hashInteger($x) === hashInteger($y).

Parameters

$value
The integer number to hash.

Returns

integer
The hash code for the given integer number.

Link

PHP interger
abstract protected integer
# hashNull( )

Returns a hash code for the null value.

Returns a hash code for the null value.

Returns

integer
The hash code for the NULL value.

Link

PHP NULL
abstract protected integer
# hashObject( object $value )

Returns a hash code for the given object.

Returns a hash code for the given object.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentObject() method, which means that for any references $x and $y, if equivalentObject($x, $y), then hashObject($x) === hashObject($y).

Parameters

$value
The object to hash.

Returns

integer
The hash code for the given object.

Link

PHP object
abstract protected integer
# hashResource( resource $value )

Returns a hash code for the given resource.

Returns a hash code for the given resource.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentResource() method, which means that for any references $x and $y, if equivalentResource($x, $y), then hashResource($x) === hashResource($y).

Parameters

$value
The resource to hash.

Returns

integer
The hash code for the given resource.

Link

PHP resource
abstract protected integer
# hashString( string $value )

Returns a hash code for the given string value.

Returns a hash code for the given string value.

The resulting hash code is guaranteed to be consistent with the PhpCommon\Comparison\Equivalence\GenericEquivalence::equivalentString() method, which means that for any references $x and $y, if equivalentString($x, $y), then hashString($x) === hashString($y).

Parameters

$value
The string value to hash.

Returns

integer
The hash code for the given object.

Link

PHP string
Methods inherited from PhpCommon\Comparison\Equivalence\GenericEquivalence
equivalent(), equivalentArray(), equivalentBoolean(), equivalentFloat(), equivalentInteger(), equivalentNull(), equivalentObject(), equivalentResource(), equivalentString()
Methods inherited from PhpCommon\Comparison\Equatable
equals()
Constants inherited from PhpCommon\Comparison\Equivalence\GenericEquivalence
TYPE_ARRAY, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_INTEGER, TYPE_NULL, TYPE_OBJECT, TYPE_RESOURCE, TYPE_STRING
PHPCommon Comparison API API documentation generated by ApiGen