public function testDefaultConstructor() { $Pace = new Pace(300); $this->assertEquals(Pace::STANDARD, $Pace->unitEnum()); }
/** * Compare * Both pace objects must have the same unit and the unit must be comparable. * @param \Runalyze\Activity\Pace $other * @param boolean $raw [optional] * @throws \InvalidArgumentException * @return string */ public function compareTo(Pace $other, $raw = false) { if ($this->unitEnum() != $other->unitEnum()) { throw new \InvalidArgumentException('Pace objects must have the same unit.'); } if ($this->secondsPerKm() == 0 || $other->secondsPerKm() == 0) { return ''; } $comparisonInSecondsPerKm = $this->UnitObject->compare($this->secondsPerKm(), $other->secondsPerKm()); $isPositive = $comparisonInSecondsPerKm >= 0; if ($comparisonInSecondsPerKm == 0 && $this->UnitObject->isTimeFormat()) { return $this->formatComparison('0:00', $isPositive, $raw); } return $this->formatComparison($this->UnitObject->format(abs($comparisonInSecondsPerKm)), $isPositive, $raw); }