Overview

Namespaces

  • PhpCommon
    • Comparison
      • Equivalence
      • Hasher

Interfaces

  • Comparable
  • Comparator
  • Equatable
  • Equivalence
  • Hashable
  • Hasher

Exceptions

  • IncomparableException
  • UnexpectedTypeException
  • Overview
  • Namespace
  • Class

Interface Equatable

Defines a method that a class implements to determine equality of instances.

For the purpose of this interface, an equivalence relation is a binary relation that is reflexive, symmetric, transitive and consistent. This equivalence relation is exposed as the Equatable::equals() method.

It is important to distinguish between a type that can be compared for equality and a representation of an equivalence relation. This interface is for representing the former, while PhpCommon\Comparison\Equivalence is for representing the latter.

Direct known implementers

PhpCommon\Comparison\Equivalence, PhpCommon\Comparison\Hashable

Indirect known implementers

PhpCommon\Comparison\Equivalence\GenericEquivalence, PhpCommon\Comparison\Hasher, PhpCommon\Comparison\Hasher\DateTimeHasher, PhpCommon\Comparison\Hasher\GenericHasher, PhpCommon\Comparison\Hasher\IdentityHasher, PhpCommon\Comparison\Hasher\ValueHasher
Namespace: PhpCommon\Comparison
Author: Marcos Passos marcos@croct.com
Located at Equatable.php
Methods summary
public boolean
# equals( PhpCommon\Comparison\Equatable $other )

Checks whether the current object is considered equal to another.

Checks whether the current object is considered equal to another.

The equals method implements an equivalence relation on non-null object references. This relation has the following properties:

  • It is reflexive: for any non-null reference value $x, $x->equals($x) should return true.
  • It is symmetric: for any non-null reference values $x and $y, $x->equals($y) should return true if and only if $y->equals($x) returns true.
  • It is transitive: for any non-null reference values $x, $y, and $z, if $x->equals($y) returns true and $y->equals($z) returns true, then $x->equals($z) should return true.
  • It is consistent: for any non-null reference values $x and $y, multiple invocations of $x->equals($y) consistently return true or consistently return false, provided $x and $y remain unchanged according to the definition of the equality.

Parameters

$other
The value to compare to.

Returns

boolean

Returns true if the current object is equal to the specified object, false otherwise.

PHPCommon Comparison API API documentation generated by ApiGen