Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
53.33% |
8 / 15 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
Document | |
53.33% |
8 / 15 |
|
66.67% |
2 / 3 |
7.54 | |
0.00% |
0 / 1 |
getModelClass | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
findOneByName | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
findOneBy | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 |
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 | |
22 | declare(strict_types=1); |
23 | |
24 | namespace App\Infrastructure\ORM\Documentation\Repository; |
25 | |
26 | use App\Application\Doctrine\Repository\CRUDRepository; |
27 | use App\Domain\Documentation\Model; |
28 | use App\Domain\Documentation\Repository; |
29 | |
30 | class Document extends CRUDRepository implements Repository\Document |
31 | { |
32 | protected function getModelClass(): string |
33 | { |
34 | return Model\Document::class; |
35 | } |
36 | |
37 | public function findOneByName(string $name) |
38 | { |
39 | $docs = $this->registry |
40 | ->getManager() |
41 | ->getRepository($this->getModelClass()) |
42 | ->findBy(['file' => $name]) |
43 | ; |
44 | if (count($docs) > 0) { |
45 | return $docs[0]; |
46 | } |
47 | } |
48 | |
49 | public function findOneBy(array $criteria) |
50 | { |
51 | $docs = $this->registry |
52 | ->getManager() |
53 | ->getRepository($this->getModelClass()) |
54 | ->findBy($criteria) |
55 | ; |
56 | if (count($docs) > 0) { |
57 | return $docs[0]; |
58 | } |
59 | } |
60 | } |