示例#1
0
文件: PaceTest.php 项目: 9x/Runalyze
 public function testDefaultConstructor()
 {
     $Pace = new Pace(300);
     $this->assertEquals(Pace::STANDARD, $Pace->unitEnum());
 }
示例#2
0
文件: Pace.php 项目: guancio/Runalyze
 /**
  * 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);
 }