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\ConfigurationFileDenormalizer as AppDenormalizer; |
7
|
|
|
use Yoanm\ComposerConfigManager\Application\Serializer\Normalizer\ConfigurationFileNormalizer as AppNormalizer; |
8
|
|
|
use Yoanm\ComposerConfigManager\Domain\Model\ConfigurationFile; |
9
|
|
|
|
10
|
|
|
class ConfigurationFileNormalizer implements NormalizerInterface, DenormalizerInterface |
11
|
|
|
{ |
12
|
|
|
/** @var AppNormalizer */ |
13
|
|
|
private $appNormalizer; |
14
|
|
|
/** @var AppDenormalizer */ |
15
|
|
|
private $appDenormalizer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param AppNormalizer $appNormalizer |
19
|
|
|
* @param AppDenormalizer $appDenormalizer |
20
|
|
|
*/ |
21
|
6 |
|
public function __construct( |
22
|
|
|
AppNormalizer $appNormalizer, |
23
|
|
|
AppDenormalizer $appDenormalizer |
24
|
|
|
) { |
25
|
6 |
|
$this->appNormalizer = $appNormalizer; |
26
|
6 |
|
$this->appDenormalizer = $appDenormalizer; |
27
|
6 |
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
1 |
|
public function normalize($object, $format = null, array $context = array()) |
33
|
|
|
{ |
34
|
1 |
|
return $this->appNormalizer->normalize($object); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
2 |
|
public function supportsNormalization($data, $format = null) |
41
|
|
|
{ |
42
|
2 |
|
return $data instanceof ConfigurationFile; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
1 |
|
public function denormalize($data, $class, $format = null, array $context = array()) |
49
|
|
|
{ |
50
|
1 |
|
return $this->appDenormalizer->denormalize($data); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
2 |
|
public function supportsDenormalization($data, $type, $format = null) |
57
|
|
|
{ |
58
|
2 |
|
return ConfigurationFile::class == $type; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|