/** * Compares the TimePoint with another instance. * The comparison is made in this order: * - reference * - target * - timestamp * - type * * CAUTION!: The result order is not based on chronological order. * Its goal is to gather TimePoint by reference and target, then sort by type and timestamp. * * @param TimePoint $point * @return int */ public function compare(TimePoint $point) { $diff = strcmp($this->getRef(), $point->getRef()); if ($diff == 0) { $diff = $this->getTarget() - $point->getTarget(); if ($diff == 0) { $diff = $this->getNormalizedTimestamp() - $point->getNormalizedTimestamp(); if ($diff == 0) { $diff = $this->getType() - $point->getType(); } } } return $diff; }