/** * {@inheritdoc} */ public function equals($object) { if ($this === $object) { return true; } if (!Test::areSameType($this, $object)) { return false; } return $this->uuid->equals($object->uuid); }
/** * {@inheritdoc} */ public function compareTo($object) { if ($this === $object) { return 0; } assert(Test::areSameType($this, $object), sprintf('Comparison requires instance of %s', static::class)); $comp = strnatcmp($this->id, $object->id); if ($comp > 0) { return 1; } if ($comp < 0) { return -1; } return 0; }
/** * {@inheritdoc} */ public function compareTo($object) { if ($this === $object) { return 0; } assert(Test::areSameType($this, $object), sprintf('Comparison requires instance of %s', static::class)); $thisStamp = $this->timestamp(); $thatStamp = $object->timestamp(); if ($thisStamp > $thatStamp) { return 1; } if ($thisStamp < $thatStamp) { return -1; } $thisMicro = $this->micro(); $thatMicro = $object->micro(); if ($thisMicro > $thatMicro) { return 1; } if ($thisMicro < $thatMicro) { return -1; } return $this->timezone->compareTo($object->timezone); }
/** * {@inheritdoc} */ public function compareTo($object) { if ($this === $object) { return 0; } assert(Test::areSameType($this, $object), sprintf('Comparison requires instance of %s', static::class)); $thisVal = $this->value; $thatVal = $object->value; $thisParts = explode('/', $thisVal); $thatParts = explode('/', $thatVal); if (count($thisParts) > 1 && count($thatParts) > 1) { return $this->compareParts($thisParts, $thatParts); } elseif (count($thisParts) > 1) { return 1; } elseif (count($thatParts) > 1) { return -1; } $comp = strnatcmp($thisVal, $thatVal); return $comp > 0 ? 1 : ($comp < 0 ? -1 : 0); }
/** * {@inheritdoc} */ public function compareTo($object) { if ($this === $object) { return 0; } assert(Test::areSameType($this, $object), sprintf('Comparison requires instance of %s', static::class)); $this->guardCurrency($object); $thisAmt = $this->amount; $thatAmt = $object->amount; if ($thisAmt > $thatAmt) { return 1; } if ($thisAmt < $thatAmt) { return -1; } return 0; }