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

YamlConsoleConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 17
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
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
}