@@ 195-210 (lines=16) @@ | ||
192 | */ |
|
193 | public function gap(ComparableIntervalInterface $interval) |
|
194 | { |
|
195 | if ($this->interval->startPoint()->gt($interval->endPoint())) { |
|
196 | $type = IntervalType::TYPE_CLOSED; |
|
197 | ||
198 | if (!$interval->type()->endExcluded()) { // invert exclude |
|
199 | $type |= IntervalType::TYPE_START_EXCLUDED; |
|
200 | } |
|
201 | ||
202 | if (!$this->interval->type()->startExcluded()) { // invert exclude |
|
203 | $type |= IntervalType::TYPE_END_EXCLUDED; |
|
204 | } |
|
205 | ||
206 | return $this->interval |
|
207 | ->withStart($interval->endPoint()) |
|
208 | ->withEnd($this->interval->startPoint()) |
|
209 | ->withType(IntervalType::create($type)); |
|
210 | } |
|
211 | ||
212 | if ($interval->startPoint()->gt($this->interval->endPoint())) { |
|
213 | $type = IntervalType::TYPE_CLOSED; |
|
@@ 212-227 (lines=16) @@ | ||
209 | ->withType(IntervalType::create($type)); |
|
210 | } |
|
211 | ||
212 | if ($interval->startPoint()->gt($this->interval->endPoint())) { |
|
213 | $type = IntervalType::TYPE_CLOSED; |
|
214 | ||
215 | if (!$this->interval->type()->endExcluded()) { // invert exclude |
|
216 | $type |= IntervalType::TYPE_START_EXCLUDED; |
|
217 | } |
|
218 | ||
219 | if (!$interval->type()->startExcluded()) { // invert exclude |
|
220 | $type |= IntervalType::TYPE_END_EXCLUDED; |
|
221 | } |
|
222 | ||
223 | return $this->interval |
|
224 | ->withStart($this->interval->endPoint()) |
|
225 | ->withEnd($interval->startPoint()) |
|
226 | ->withType(IntervalType::create($type)); |
|
227 | } |
|
228 | ||
229 | return null; // no gap |
|
230 | } |