/** * @param Pause $pause * @return bool */ public function isOverlapping(Pause $pause) { if ($this->getEnd() <= $pause->getStart()) { return false; } if ($this->getStart() >= $pause->getEnd()) { return false; } return true; }
/** * @param Pause $pause */ private function addPause(Pause $pause) { if ($pause->getStart() < $this->getArrival()) { throw new \InvalidArgumentException(); } if ($pause->getEnd() > $this->getDeparture()) { throw new \InvalidArgumentException(); } if ($this->isPauseOverlapping($pause)) { throw new \InvalidArgumentException(); } $this->pauseList[] = $pause; }