Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Question | |
0.00% |
0 / 24 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
getModelClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
findAllByProcessus | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
findNewNotUsedByGivenConformite | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\Infrastructure\ORM\Registry\Repository\ConformiteOrganisation; |
4 | |
5 | use App\Application\Doctrine\Repository\CRUDRepository; |
6 | use App\Domain\Registry\Model\ConformiteOrganisation as Model; |
7 | use App\Domain\Registry\Repository; |
8 | |
9 | class Question extends CRUDRepository implements Repository\ConformiteOrganisation\Question |
10 | { |
11 | protected function getModelClass(): string |
12 | { |
13 | return Model\Question::class; |
14 | } |
15 | |
16 | public function findAllByProcessus(Model\Processus $processus) |
17 | { |
18 | return $this->createQueryBuilder() |
19 | ->andWhere('o.processus = :processus') |
20 | ->setParameter('processus', $processus->getId()) |
21 | ->addOrderBy('o.position', 'ASC') |
22 | ->getQuery() |
23 | ->getResult() |
24 | ; |
25 | } |
26 | |
27 | public function findNewNotUsedByGivenConformite(Model\Conformite $conformite) |
28 | { |
29 | $qb = $this->createQueryBuilder(); |
30 | $qb->andWhere('o.processus = :processus'); |
31 | $qb->setParameter('processus', $conformite->getProcessus()); |
32 | if (!empty($conformite->getReponses())) { |
33 | $qb->andWhere($qb->expr()->notIn('o.id', ':questions')) |
34 | ->setParameter( |
35 | 'questions', |
36 | array_map(function (Model\Reponse $reponse) { |
37 | return $reponse->getQuestion()->getId()->toString(); |
38 | }, \iterable_to_array($conformite->getReponses())) |
39 | ) |
40 | ; |
41 | } |
42 | |
43 | return $qb |
44 | ->getQuery() |
45 | ->getResult() |
46 | ; |
47 | } |
48 | } |