Skip to content

Commit

Permalink
change typehints to iterable, so we can accept Generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Warxcell committed Apr 8, 2021
1 parent fad98e1 commit eb566d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function getFilter($name): callable
/** @return QueryBuilder */
abstract public function createQueryBuilder($alias, $indexBy = null);

public function createQueryBuilderByFilters(string $alias, array $filterBy, $indexBy = null): QueryBuilder
public function createQueryBuilderByFilters(string $alias, iterable $filterBy, string $indexBy = null): QueryBuilder
{
$queryBuilder = $this->createQueryBuilder($alias, $indexBy);
$queryBuilder->filters = [];
Expand Down Expand Up @@ -66,22 +66,22 @@ public function appendFilter(QueryBuilder $queryBuilder, string $alias, string $
return $queryBuilder->filters[$filterName] = true;
}

public function findOneByFilters(array $filterBy)
public function findOneByFilters(iterable $filterBy)
{
return $this->createQueryBuilderByFilters('entity', $filterBy)->getQuery()->getOneOrNullResult();
}

public function findByFilters(array $filterBy)
public function findByFilters(iterable $filterBy)
{
return $this->createQueryBuilderByFilters('entity', $filterBy)->getQuery()->getResult();
}

public function getSingleResultByFilters(array $filterBy)
public function getSingleResultByFilters(iterable $filterBy)
{
return $this->createQueryBuilderByFilters('entity', $filterBy)->getQuery()->getSingleResult();
}

public function countByFilters(array $filterBy): int
public function countByFilters(iterable $filterBy): int
{
return (int)$this
->createQueryBuilderByFilters('entity', $filterBy)
Expand Down

0 comments on commit eb566d8

Please sign in to comment.