Skip to content

Commit

Permalink
refactor: remove criteria from __construct
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Feb 15, 2024
1 parent daef51e commit 68c663a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.1.3

* Improve lazy-matching test.
* refactor: remove criteria from __construct

## 2.1.2

Expand Down
3 changes: 2 additions & 1 deletion src/LazyMatching/LazyMatchingCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LazyMatchingCollection extends SelectableCollectionDecorator
{
public function matching(Criteria $criteria): ReadableCollection&Selectable
{
return new LazyMatchingReadableCollection($this->getWrapped(), $criteria);
return (new LazyMatchingReadableCollection($this->getWrapped()))
->matching($criteria);
}
}
4 changes: 2 additions & 2 deletions src/LazyMatching/LazyMatchingReadableCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class LazyMatchingReadableCollection extends SelectableReadableCollectionDecorat
* @var null|(ReadableCollection<TKey,T>&Selectable<TKey,T>)
*/
private $resultCache = null;
private ?Criteria $criteria = null;

/**
* @param ReadableCollection<TKey,T> $collection
*/
public function __construct(
ReadableCollection $collection,
private ?Criteria $criteria = null
ReadableCollection $collection
) {
if (!$collection instanceof Selectable) {
throw new \InvalidArgumentException('Collection must be selectable');
Expand Down

0 comments on commit 68c663a

Please sign in to comment.