Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Question
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 getModelClass
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 findNewQuestionsNotUseInGivenConformite
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22declare(strict_types=1);
23
24namespace App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement;
25
26use App\Application\Doctrine\Repository\CRUDRepository;
27use App\Domain\Registry\Model;
28use App\Domain\Registry\Repository;
29
30class Question extends CRUDRepository implements Repository\ConformiteTraitement\Question
31{
32    protected function getModelClass(): string
33    {
34        return Model\ConformiteTraitement\Question::class;
35    }
36
37    public function findNewQuestionsNotUseInGivenConformite(Model\ConformiteTraitement\ConformiteTraitement $conformiteTraitement)
38    {
39        $qb = $this->createQueryBuilder();
40
41        $params = array_map(function (Model\ConformiteTraitement\Reponse $reponse) {
42            return $reponse->getQuestion()->getId()->toString();
43        }, \iterable_to_array($conformiteTraitement->getReponses()))
44        ;
45
46        if (count($params)) {
47            $qb->andWhere($qb->expr()->notIn('o.id', ':questions'))
48                ->setParameter(
49                    'questions',
50                    $params
51                )
52            ;
53        }
54
55        return $qb
56            ->getQuery()
57            ->getResult()
58        ;
59    }
60}