Skip to content

Commit

Permalink
Remove Without method
Browse files Browse the repository at this point in the history
Reason being that you should pass an inverted version of the closure to the filter method, effectively doing the same thing.

Signed-off-by: Yoshi2889 <rick.2889@gmail.com>
  • Loading branch information
NanoSector committed Jun 29, 2017
1 parent 80e5da1 commit d059646
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
15 changes: 0 additions & 15 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,6 @@ public function filter(\Closure $condition): Collection
return $collection;
}

/**
* @param \Closure $condition
*
* @return Collection
*/
public function without(\Closure $condition): Collection
{
$collection = new self($this->validator);
foreach ((array) $this as $offset => $value)
if (!$condition($value))
$collection->offsetSet($offset, $value);

return $collection;
}

/**
* @param mixed $value
*
Expand Down
14 changes: 0 additions & 14 deletions tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,4 @@ public function testFilter()
self::assertEquals(['Test', 'ing', 'something'], $filteredCollection->values());
self::assertEquals(3, $filteredCollection->count());
}

public function testWithout()
{
$initialValues = ['Test', 'ing', 'something', 'else'];
$collection = new Collection($this->getStringValidatorClosure(), $initialValues);

$filteredCollection = $collection->without(function (string $value)
{
return $value != 'else';
});

self::assertEquals(['else'], $filteredCollection->values());
self::assertEquals(1, $filteredCollection->count());
}
}

0 comments on commit d059646

Please sign in to comment.