public function __construct(Measurement $start, Measurement $end) { if ($start->isGreaterThan($end)) { throw new \LengthException('Start of the range cannot be larger than the end'); } $this->start = $start; $this->end = $end; }
public function compare(Measurement $measurement) { $diff = Comparable::GREATER_THAN; if ($measurement->isLessThan($this->getStart())) { $diff = Comparable::LESS_THAN; } elseif ($measurement->isLessThan($this->getEnd())) { $diff = Comparable::EQUAL_TO; } return (int) $diff; }
public function compare(Measurement $measurement) { return bccomp($this->toBase(), $measurement->toBase()); }