Failed Conditions
Pull Request — master (#10)
by Yo
02:50
created

ConfigurationNormalizer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 2
cbo 2
dl 0
loc 51
ccs 8
cts 12
cp 0.6667
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 4 1
A __construct() 0 7 1
A supportsNormalization() 0 4 1
A denormalize() 0 4 1
A supportsDenormalization() 0 4 1
1
<?php
2
namespace Yoanm\ComposerConfigManager\Infrastructure\Serializer\Normalizer;
3
4
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
5
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
6
use Yoanm\ComposerConfigManager\Application\Serializer\Normalizer\ConfigurationNormalizer as AppConfigNormalizer;
7
use Yoanm\ComposerConfigManager\Application\Serializer\Normalizer\ConfigurationDenormalizer as AppConfigDenormalizer;
8
use Yoanm\ComposerConfigManager\Domain\Model\Configuration;
9
10
class ConfigurationNormalizer implements NormalizerInterface, DenormalizerInterface
11
{
12
    /** @var AppConfigNormalizer */
13
    private $appConfigurationNormalizer;
14
    /** @var AppConfigDenormalizer */
15
    private $appConfigurationDenormalizer;
16
17
    /**
18
     * @param AppConfigNormalizer $appConfigurationNormalizer
19
     * @param AppConfigDenormalizer $appConfigurationDenormalizer
20
     */
21 3
    public function __construct(
22
        AppConfigNormalizer $appConfigurationNormalizer,
23
        AppConfigDenormalizer $appConfigurationDenormalizer
24
    ) {
25 3
        $this->appConfigurationNormalizer = $appConfigurationNormalizer;
26 3
        $this->appConfigurationDenormalizer = $appConfigurationDenormalizer;
27 3
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function normalize($object, $format = null, array $context = array())
33
    {
34 1
        return $this->appConfigurationNormalizer->normalize($object);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function supportsNormalization($data, $format = null)
41
    {
42 2
        return $data instanceof Configuration;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function denormalize($data, $class, $format = null, array $context = array())
49
    {
50
        return $this->appConfigurationDenormalizer->denormalize($data);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function supportsDenormalization($data, $type, $format = null)
57
    {
58
        return Configuration::class == $type;
59
    }
60
}
61