Passed
Push — develop ( 45600c...ff69f6 )
by Paul
03:16
created

YamlConsoleConfig::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace PhpUnitGen\Configuration;
4
5
use PhpUnitGen\Exception\InvalidConfigException;
6
use Symfony\Component\Yaml\Exception\ParseException;
7
use Symfony\Component\Yaml\Yaml;
8
9
/**
10
 * Class YamlConsoleConfig.
11
 *
12
 * @author     Paul Thébaud <[email protected]>.
13
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
14
 * @license    https://opensource.org/licenses/MIT The MIT license.
15
 * @link       https://github.com/paul-thebaud/phpunit-generator
16
 * @since      Class available since Release 2.0.0.
17
 */
18
class YamlConsoleConfig extends ConsoleConfig
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function __construct($config)
24
    {
25
        try {
26
            $config = Yaml::parse($config);
27
        } catch (ParseException $exception) {
28
            throw new InvalidConfigException(sprintf(
29
                'Unable to parse YAML config: %s',
30
                $exception->getMessage()
31
            ));
32
        }
33
34
        parent::__construct($config);
35
    }
36
}