Пример #1
0
 public function __construct(Length $start, Length $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(Length $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;
 }
Пример #3
0
 public function compare(Length $length)
 {
     return bccomp($this->toBase(), $length->toBase());
 }