MetadataPass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 1
1
<?php
2
3
namespace Happyr\SerializerBundle\DependencyInjection\CompilerPass;
4
5
use Happyr\SerializerBundle\Metadata\Metadata;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
9
/**
10
 * Collect and give the metadata to the normalizers.
11
 *
12
 * @author Tobias Nyholm <[email protected]>
13
 */
14
class MetadataPass implements CompilerPassInterface
15
{
16 23
    public function process(ContainerBuilder $container)
17
    {
18 23
        $provider = $container->get('happyr.serializer.metadata.metadata_provider');
19 23
        $metadata = $provider->getMetadata();
20
21 23
        $normalizerDef = $container->getDefinition('happyr.serializer.normalizer.metadata_aware');
22 23
        $metadataString = Metadata::convertToStrings($metadata);
23 23
        $normalizerDef->replaceArgument(0, $metadataString);
24
25 23
        $normalizerDef = $container->getDefinition('happyr.serializer.denormalizer.metadata_aware');
26 23
        $normalizerDef->replaceArgument(0, $metadataString);
27 23
    }
28
}
29