Completed
Push — master ( cf2a09...095f44 )
by WEBEWEB
01:14
created

WBWSMSModeExtension   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 3 1
B load() 0 27 6
1
<?php
2
3
/*
4
 * This file is part of the smsmode-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\SMSModeBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Extension\Extension;
17
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
18
19
/**
20
 * sMsmode extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\SMSModeBundle\DependencyInjection
24
 */
25
class WBWSMSModeExtension extends Extension {
26
27
    /**
28
     * {@inheritDoc}
29
     */
30
    public function getAlias(){
31
        return "wbw_smsmode";
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function load(array $configs, ContainerBuilder $container) {
38
39
        $fileLocator = new FileLocator(__DIR__ . "/../Resources/config");
40
41
        $serviceLoader = new YamlFileLoader($container, $fileLocator);
42
        $serviceLoader->load("services.yml");
43
44
        $configuration = $this->getConfiguration($configs, $container);
45
46
        $config = $this->processConfiguration($configuration, $configs);
0 ignored issues
show
Documentation introduced by
$configuration is of type null|object, but the function expects a object<Symfony\Component...ConfigurationInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
48
        if (true === array_key_exists("authentication", $config)) {
49
            if (true === array_key_exists("access_token", $config["authentication"])) {
50
                $container->setParameter("smsmode.access_token", $config["authentication"]["access_token"]);
51
            }
52
            if (true === array_key_exists("pseudo", $config["authentication"])) {
53
                $container->setParameter("smsmode.pseudo", $config["authentication"]["pseudo"]);
54
            }
55
            if (true === array_key_exists("pass", $config["authentication"])) {
56
                $container->setParameter("smsmode.pass", $config["authentication"]["pass"]);
57
            }
58
        }
59
60
        if (true === $config["event_listeners"]) {
61
            $serviceLoader->load("event_listeners.yml");
62
        }
63
    }
64
}
65