Skip to content

Commit

Permalink
Add invert() on all interval sets
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Feb 17, 2021
1 parent d911bfc commit 3424ae4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Math/Interval/FloatIntervalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public function subtractIntervals(FloatInterval ...$intervals): self
return new static($results);
}

public function invert(): self
{
return (new static([FloatInterval::all()]))->subtract($this);
}

/**
* Intersect with another set of intervals.
* @param self $set
Expand Down
5 changes: 5 additions & 0 deletions src/Math/Interval/IntIntervalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public function subtractIntervals(IntInterval ...$intervals): self
return new static($results);
}

public function invert(): self
{
return (new static([IntInterval::all()]))->subtract($this);
}

/**
* Intersect with another set of intervals.
* @param self $set
Expand Down
5 changes: 5 additions & 0 deletions src/Time/Interval/DateIntervalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ public function subtractIntervals(DateInterval ...$intervals): self
return new static($results);
}

public function invert(): self
{
return (new static([DateInterval::all()]))->subtract($this);
}

/**
* Intersect with another set of intervals.
* @param self $set
Expand Down
5 changes: 5 additions & 0 deletions src/Time/Interval/NightIntervalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public function subtractIntervals(NightInterval ...$intervals): self
return new static($results);
}

public function invert(): self
{
return (new static([NightInterval::all()]))->subtract($this);
}

/**
* Intersect with another set of intervals.
* @param self $set
Expand Down
5 changes: 5 additions & 0 deletions src/Time/Interval/TimeIntervalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ public function subtractIntervals(TimeInterval ...$intervals): self
return new static($results);
}

public function invert(): self
{
return (new static([TimeInterval::all()]))->subtract($this);
}

/**
* Intersect with another set of intervals.
* @param self $set
Expand Down

0 comments on commit 3424ae4

Please sign in to comment.