Skip to content

Commit

Permalink
filter/without: Preserve keys
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshi2889 <[email protected]>
  • Loading branch information
NanoSector committed Jun 29, 2017
1 parent e4da648 commit 80e5da1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(\Closure $valueValidator, array $initialValues = [])
public function filter(\Closure $condition): Collection
{
$collection = new self($this->validator);
foreach ($this->values() as $offset => $value)
foreach ((array) $this as $offset => $value)
if ($condition($value))
$collection->offsetSet($offset, $value);

Expand All @@ -58,7 +58,7 @@ public function filter(\Closure $condition): Collection
public function without(\Closure $condition): Collection
{
$collection = new self($this->validator);
foreach ($this->values() as $offset => $value)
foreach ((array) $this as $offset => $value)
if (!$condition($value))
$collection->offsetSet($offset, $value);

Expand Down

0 comments on commit 80e5da1

Please sign in to comment.