diff --git a/src/SetTrait.php b/src/SetTrait.php index 35105f5..85c38f8 100644 --- a/src/SetTrait.php +++ b/src/SetTrait.php @@ -103,6 +103,16 @@ public function diff(self $otherSet): self return $result; } + /** + * @return static + */ + public function diffByKey(self $otherSet): self + { + $result = new self; + $result->items = \array_diff_key($this->items, $otherSet->items); + return $result; + } + public function overlaps(self $otherSet): bool { foreach ($this->items as $key => $item) {