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