Completed
Push — master ( 1494d2...398a9b )
by dan
02:07
created

BroadcasterFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 21 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\DependencyInjection\Factory;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Definition;
7
8
class BroadcasterFactory
9
{
10
    public function create(ContainerBuilder $container, $name, array $config)
11
    {
12
        $type = array_keys($config)[0];
13
        $parameterName = 'notification.broadcast.config.' . $name;
14
        $serviceName = 'notification.broadcast.' . $name;
15
        $channelServiceName = 'notification.channel.' . $type;
16
17
        $container->setParameter($parameterName, $config[$type]);
18
19
        $definition = new Definition();
20
        $definition->setClass('IrishDan\NotificationBundle\Broadcast\Broadcaster');
21
        $definition->setArguments(
22
            [
23
                '@notification.broadcast.notifiable',
24
                '@' . $channelServiceName,
25
                '%' . $parameterName . '%',
26
            ]
27
        );
28
29
        $container->setDefinition($serviceName, $definition);
30
    }
31
}
32