PhpConsoleConfigFactory::decode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of PhpUnitGen.
5
 *
6
 * (c) 2017-2018 Paul Thébaud <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpUnitGen\Configuration;
13
14
use PhpUnitGen\Exception\InvalidConfigException;
15
16
/**
17
 * Class PhpConsoleConfigFactory.
18
 *
19
 * @author     Paul Thébaud <[email protected]>.
20
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
21
 * @license    https://opensource.org/licenses/MIT The MIT license.
22
 * @link       https://github.com/paul-thebaud/phpunit-generator
23
 * @since      Class available since Release 2.0.0.
24
 */
25
class PhpConsoleConfigFactory extends AbstractConsoleConfigFactory
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function decode(string $configPath): array
31
    {
32
        $configArray = require $configPath;
33
        if (! is_array($configArray)) {
34
            throw new InvalidConfigException('Invalid PHP config');
35
        }
36
        return $configArray;
37
    }
38
}
39