public function compareTo(MockSimplePeriod $otherPeriod) { if ($this->unit->equals($otherPeriod->getUnit()) == false) { throw new IllegalArgumentException("Units cannot be compared: " . $this->unit . " and " . $otherPeriod->getUnit()); } return Long::compare($this->amount, $otherPeriod->amount); }