Completed
Push — master ( 233b30...e5e762 )
by Saulius
02:40
created

SaulsComponentsExtension::componentIsNotEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * This file is part of the sauls/components-bundle package.
4
 *
5
 * @author    Saulius Vaičeliūnas <[email protected]>
6
 * @link      http://saulius.vaiceliunas.lt
7
 * @copyright 2018
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Sauls\Bundle\Components\DependencyInjection;
14
15
use function Sauls\Component\Helper\array_get_value;
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\Config\Loader\LoaderInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Extension\Extension;
20
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
21
22
class SaulsComponentsExtension extends Extension
23
{
24
    /**
25
     * @throws \Exception
26
     * @throws \Sauls\Component\Helper\Exception\PropertyNotAccessibleException
27
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
28
     */
29 4
    public function load(array $configs, ContainerBuilder $container)
30
    {
31 4
        $loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
32
33 4
        $this->loadHelpersConfiguration($configs, $container, $loader);
34 4
        $this->loadWidgetsConfiguration($configs, $container, $loader);
35 4
    }
36
37
    /**
38
     * @throws \Exception
39
     * @throws \Sauls\Component\Helper\Exception\PropertyNotAccessibleException
40
     */
41 4
    private function loadHelpersConfiguration(array $configs, ContainerBuilder $container, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
    private function loadHelpersConfiguration(array $configs, /** @scrutinizer ignore-unused */ ContainerBuilder $container, LoaderInterface $loader)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43 4
        if ($this->componentIsNotEnabled('helpers', $configs)) {
44 1
            return;
45
        }
46
47 3
        $loader->load('helpers.yaml');
48 3
    }
49
50
    /**
51
     * @throws \Exception
52
     * @throws \Sauls\Component\Helper\Exception\PropertyNotAccessibleException
53
     */
54 4
    private function loadWidgetsConfiguration(array $configs, ContainerBuilder $container, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

54
    private function loadWidgetsConfiguration(array $configs, /** @scrutinizer ignore-unused */ ContainerBuilder $container, LoaderInterface $loader)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56 4
        if ($this->componentIsNotEnabled('widgets', $configs)) {
57 1
            return;
58
        }
59
60 3
        $loader->load('widgets.yaml');
61 3
    }
62
63
    /**
64
     * @throws \Exception
65
     * @throws \Sauls\Component\Helper\Exception\PropertyNotAccessibleException
66
     */
67 4
    private function componentIsNotEnabled(string $componentName, array $configs): bool
0 ignored issues
show
Unused Code introduced by
The parameter $componentName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

67
    private function componentIsNotEnabled(/** @scrutinizer ignore-unused */ string $componentName, array $configs): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69 4
        return false === array_get_value($configs, 'helpers', false);
70
    }
71
}
72