Passed
Push — master ( 674a40...295c83 )
by Vitaliy
03:18
created

NormalizeNormalizableResourcesListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onAfterDenormalize() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the FiveLab Resource package
7
 *
8
 * (c) FiveLab
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace FiveLab\Component\Resource\Resource\EventListener;
15
16
use FiveLab\Component\Resource\Resource\NormalizableResourceInterface;
17
use FiveLab\Component\Resource\Serializer\Events\AfterDenormalizationEvent;
18
19
/**
20
 * Listener for normalize normalizable resources.
21
 */
22
class NormalizeNormalizableResourcesListener
23
{
24
    /**
25
     * Call to this method after denormalize
26
     *
27
     * @param AfterDenormalizationEvent $event
28
     */
29 2
    public function onAfterDenormalize(AfterDenormalizationEvent $event): void
30
    {
31 2
        $resource = $event->getResource();
32
33 2
        if ($resource instanceof NormalizableResourceInterface) {
34 1
            $resource->normalize();
35
        }
36 2
    }
37
}
38