Interfaces and helper trait for comparing objects.
Equalable interface
$this->equals($that); // True if $this is equal to $that
Comparable interface
Extends Equalable interface
$this->greaterThan($that); // True if $this is greater than $that
$this->greaterThanOrEqual($that); // True if $this is greater than or equal to $that
$this->lessThan($that); // True if $this is less than $that
$this->lessThanOrEqual($that); // True if $this is less than or equal to $that
// 0 if $this is equal to $that
// -1 if $this is less than $that
// 1 if $this is greater than $that
$this->compare($that);
Comparison trait
A class using this trait only has to implement the compare() method.
Methods equals(), greaterThan(), greaterThanOrEqual(), lessThan() and lessThanOrEqual() will be provided by the trait, based on the result of compare().