Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| DoctrineQueryBuilder | |
100.00% |
13 / 13 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| andWhere | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setParameter | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setFirstResult | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setMaxResults | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| count | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Specification; |
| 4 | |
| 5 | use Doctrine\ORM\QueryBuilder; |
| 6 | |
| 7 | /** |
| 8 | * @author Wilhelm Zwertvaegher |
| 9 | */ |
| 10 | class DoctrineQueryBuilder implements QueryBuilderInterface |
| 11 | { |
| 12 | public function __construct(private QueryBuilder $queryBuilder) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | public function andWhere(string $where): QueryBuilderInterface |
| 17 | { |
| 18 | $this->queryBuilder->andWhere($where); |
| 19 | |
| 20 | return $this; |
| 21 | } |
| 22 | |
| 23 | public function setParameter(string $field, mixed $value): QueryBuilderInterface |
| 24 | { |
| 25 | $this->queryBuilder->setParameter($field, $value); |
| 26 | |
| 27 | return $this; |
| 28 | } |
| 29 | |
| 30 | public function setFirstResult(int $firstResult): QueryBuilderInterface |
| 31 | { |
| 32 | $this->queryBuilder->setFirstResult($firstResult); |
| 33 | |
| 34 | return $this; |
| 35 | } |
| 36 | |
| 37 | public function setMaxResults(int $maxResult): QueryBuilderInterface |
| 38 | { |
| 39 | $this->queryBuilder->setMaxResults($maxResult); |
| 40 | |
| 41 | return $this; |
| 42 | } |
| 43 | |
| 44 | public function count(string $field): int |
| 45 | { |
| 46 | return (int) (clone $this->queryBuilder) |
| 47 | ->select(sprintf('COUNT(%s)', $field)) |
| 48 | ->getQuery() |
| 49 | ->getSingleScalarResult(); |
| 50 | } |
| 51 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 12 | public function __construct(private QueryBuilder $queryBuilder) |
| 13 | { |
| 14 | } |
| 16 | public function andWhere(string $where): QueryBuilderInterface |
| 17 | { |
| 18 | $this->queryBuilder->andWhere($where); |
| 19 | |
| 20 | return $this; |
| 21 | } |
| 44 | public function count(string $field): int |
| 45 | { |
| 46 | return (int) (clone $this->queryBuilder) |
| 47 | ->select(sprintf('COUNT(%s)', $field)) |
| 48 | ->getQuery() |
| 49 | ->getSingleScalarResult(); |
| 50 | } |
| 30 | public function setFirstResult(int $firstResult): QueryBuilderInterface |
| 31 | { |
| 32 | $this->queryBuilder->setFirstResult($firstResult); |
| 33 | |
| 34 | return $this; |
| 35 | } |
| 37 | public function setMaxResults(int $maxResult): QueryBuilderInterface |
| 38 | { |
| 39 | $this->queryBuilder->setMaxResults($maxResult); |
| 40 | |
| 41 | return $this; |
| 42 | } |
| 23 | public function setParameter(string $field, mixed $value): QueryBuilderInterface |
| 24 | { |
| 25 | $this->queryBuilder->setParameter($field, $value); |
| 26 | |
| 27 | return $this; |
| 28 | } |
| 3 | namespace App\Specification; |
| 4 | |
| 5 | use Doctrine\ORM\QueryBuilder; |
| 6 | |
| 7 | /** |
| 8 | * @author Wilhelm Zwertvaegher |
| 9 | */ |
| 10 | class DoctrineQueryBuilder implements QueryBuilderInterface |
| 11 | { |
| 12 | public function __construct(private QueryBuilder $queryBuilder) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | public function andWhere(string $where): QueryBuilderInterface |
| 17 | { |
| 18 | $this->queryBuilder->andWhere($where); |
| 19 | |
| 20 | return $this; |
| 21 | } |
| 22 | |
| 23 | public function setParameter(string $field, mixed $value): QueryBuilderInterface |
| 24 | { |
| 25 | $this->queryBuilder->setParameter($field, $value); |
| 26 | |
| 27 | return $this; |
| 28 | } |
| 29 | |
| 30 | public function setFirstResult(int $firstResult): QueryBuilderInterface |
| 31 | { |
| 32 | $this->queryBuilder->setFirstResult($firstResult); |
| 33 | |
| 34 | return $this; |
| 35 | } |
| 36 | |
| 37 | public function setMaxResults(int $maxResult): QueryBuilderInterface |
| 38 | { |
| 39 | $this->queryBuilder->setMaxResults($maxResult); |
| 40 | |
| 41 | return $this; |
| 42 | } |
| 43 | |
| 44 | public function count(string $field): int |
| 45 | { |
| 46 | return (int) (clone $this->queryBuilder) |
| 47 | ->select(sprintf('COUNT(%s)', $field)) |
| 48 | ->getQuery() |
| 49 | ->getSingleScalarResult(); |
| 50 | } |