Class DateTimeHasher
An equivalence relation to determine whether two instances of
DateTime have the same date, time and time zone.
-
PhpCommon\Comparison\Hasher\DateTimeHasher
implements
PhpCommon\Comparison\Hasher
Methods summary
public
boolean
|
#
equals( PhpCommon\Comparison\Equatable $other )
Checks whether the current relation is considered equal to another.
Checks whether the current relation is considered equal to another.
Since this class is stateless, its instances will always be considered
equal if they are of the same type.
Parameters
- $other
- The value to compare to.
Returns
boolean Returns true if the current object is equal to the
specified object, false otherwise.
Implementation of
|
public
boolean
|
#
equivalent( DateTimeInterface $left, mixed $right )
Checks whether the given values are considered equivalent.
Checks whether the given values are considered equivalent.
This equivalence relation considers two instances of DateTimeInterface to
be equivalent if they have the same date, time and time zone.
Parameters
- $left
- The date/time to compare.
- $right
- The value to compare.
Returns
boolean Returns true if the date/time are considered
equivalent, false otherwise.
Throws
Implementation of
|
public
integer
|
#
hash( DateTimeInterface $value )
Returns a hash code for the given DateTime instance.
Returns a hash code for the given DateTime instance.
The resulting hash code is guaranteed to be coherent with the
PhpCommon\Comparison\Hasher\DateTimeHasher::equivalent() method, which means that for any references
$x and $y , if equivalent($x, $y) , then hash($x) === hash($y) .
It is computed by summing the values returned by the methods
\DateTimeInterface::getTimestamp() and
\DateTimeInterface::getOffset(), as shown in the following
expression:
$hashCode = $date->getTimestamp() + $date->getOffset();
Parameters
- $value
- The date/time to compare.
Returns
integer The hash code.
Throws
See
Implementation of
|
protected
|
#
assertDateTime( mixed $value )
Asserts the given value is an instance of DateTimeInterface.
Asserts the given value is an instance of DateTimeInterface.
Parameters
- $value
- The value to assert.
Throws
|