Completed
Pull Request — master (#6)
by Pavel
14:37
created

JmsSerializerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
ccs 13
cts 14
cp 0.9286
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 21 2
1
<?php
2
3
namespace Bankiru\Api\JsonRpc\DependencyInjection\Compiler;
4
5
use Bankiru\Api\JsonRpc\Listener\SerializedJsonRpcResponseListener;
6
use Bankiru\Api\Rpc\RpcEvents;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class JmsSerializerPass implements CompilerPassInterface
12
{
13
    /** {@inheritdoc} */
14 1
    public function process(ContainerBuilder $container)
15
    {
16 1
        if (!$container->has('jms_serializer')) {
17
            return;
18
        }
19
20 1
        $definition = $container->register('jsonrpc.view.serialize_response', SerializedJsonRpcResponseListener::class);
21 1
        $definition->setArguments(
22
            [
23 1
                new Reference('jms_serializer'),
24
            ]
25 1
        );
26 1
        $definition->addTag(
27 1
            'kernel.event_listener',
28
            [
29 1
                'event'    => RpcEvents::VIEW,
30 1
                'method'   => 'onPlainResponse',
31 1
                'priority' => -254,
32
            ]
33 1
        );
34 1
    }
35
}
36