VreshTwilioExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 2 Features 2
Metric Value
c 6
b 2
f 2
dl 0
loc 20
rs 9.4285
cc 1
eloc 16
nc 1
nop 2
1
<?php
2
namespace Vresh\TwilioBundle\DependencyInjection;
3
4
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
5
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Config\FileLocator;
8
9
/**
10
 * This file is part of the VreshTwilioBundle.
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 *
15
 * @author Fridolin Koch <[email protected]>
16
 */
17
class VreshTwilioExtension extends Extension
18
{
19
    /**
20
     * @param array            $configs
21
     * @param ContainerBuilder $container
22
     */
23
    public function load(array $configs, ContainerBuilder $container)
24
    {
25
        $loader = new YamlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config')));
26
        $loader->load('services.yml');
27
28
        $configuration = new Configuration();
29
        $config = $this->processConfiguration($configuration, $configs);
30
31
        $container->getDefinition('twilio.api')
32
            ->addArgument($config['sid'])
33
            ->addArgument($config['authToken'])
34
            ->addArgument($config['version'])
35
            ->addArgument($config['retryAttempts']);
36
        $container->getDefinition('twilio.capability')
37
            ->addArgument($config['sid'])
38
            ->addArgument($config['authToken']);
39
        $container->getDefinition('twilio.lookups')
40
            ->addArgument($config['sid'])
41
            ->addArgument($config['authToken']);
42
    }
43
}
44