Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
ConformiteOrganisationSubscriber | |
100.00% |
10 / 10 |
|
100.00% |
5 / 5 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSubscribedEvents | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
prePersist | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
preUpdate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
processConformiteOrganisation | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace App\Domain\Registry\Symfony\EventSubscriber\Doctrine; |
6 | |
7 | use App\Domain\Registry\Calculator\ConformiteOrganisationConformiteCalculator; |
8 | use App\Domain\Registry\Model\ConformiteOrganisation\Evaluation; |
9 | use Doctrine\Common\EventSubscriber; |
10 | use Doctrine\ORM\Event\LifecycleEventArgs; |
11 | |
12 | class ConformiteOrganisationSubscriber implements EventSubscriber |
13 | { |
14 | /** |
15 | * @var ConformiteOrganisationConformiteCalculator |
16 | */ |
17 | private $conformiteCalculator; |
18 | |
19 | public function __construct(ConformiteOrganisationConformiteCalculator $calculator) |
20 | { |
21 | $this->conformiteCalculator = $calculator; |
22 | } |
23 | |
24 | public function getSubscribedEvents() |
25 | { |
26 | return [ |
27 | 'prePersist', |
28 | 'preUpdate', |
29 | ]; |
30 | } |
31 | |
32 | public function prePersist(LifecycleEventArgs $args) |
33 | { |
34 | $this->processConformiteOrganisation($args); |
35 | } |
36 | |
37 | public function preUpdate(LifecycleEventArgs $args) |
38 | { |
39 | $this->processConformiteOrganisation($args); |
40 | } |
41 | |
42 | private function processConformiteOrganisation(LifecycleEventArgs $args) |
43 | { |
44 | if (!($evaluation = $args->getObject()) instanceof Evaluation) { |
45 | return; |
46 | } |
47 | |
48 | $this->conformiteCalculator->calculEvaluationConformites($evaluation); |
49 | } |
50 | } |