Completed
Pull Request — master (#18)
by Tomáš
04:24
created

MultiCodingStandardExtension::setConfigToContainerBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\MultiCodingStandard\DI;
11
12
use Nette\DI\CompilerExtension;
13
14
final class MultiCodingStandardExtension extends CompilerExtension
15
{
16
    public function loadConfiguration()
17
    {
18
        $this->loadServicesFromConfigPath(__DIR__.'/../config/services.neon');
19
    }
20
21
    private function loadServicesFromConfigPath(string $configPath)
22
    {
23
        $containerBuilder = $this->getContainerBuilder();
24
        $config = $this->loadFromFile($configPath);
25
        $this->compiler->parseServices($containerBuilder, $config);
0 ignored issues
show
Bug introduced by
It seems like $config defined by $this->loadFromFile($configPath) on line 24 can also be of type string; however, Nette\DI\Compiler::parseServices() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Deprecated Code introduced by
The method Nette\DI\Compiler::parseServices() has been deprecated.

This method has been deprecated.

Loading history...
26
    }
27
}
28