Failed Conditions
Push — master ( 10368b...49930d )
by Andreas
12:05
created

YamlConfiguration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 24
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A doLoad() 0 18 4
1
<?php
2
3
namespace Doctrine\DBAL\Migrations\Configuration;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
use Doctrine\DBAL\Migrations\MigrationException;
8
9
/**
10
 * Load migration configuration information from a YAML configuration file.
11
 *
12
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
13
 * @link        www.doctrine-project.org
14
 * @since       2.0
15
 * @author      Jonathan H. Wage <[email protected]>
16
 */
17
class YamlConfiguration extends AbstractFileConfiguration
18
{
19
    /**
20
     * @inheritdoc
21
     */
22 29
    protected function doLoad($file)
23
    {
24 29
        if ( ! class_exists(Yaml::class)) {
25
            throw MigrationException::yamlConfigurationNotAvailable();
26
        }
27
28 29
        $config = Yaml::parse(file_get_contents($file));
29
30 29
        if ( ! is_array($config)) {
31
            throw new \InvalidArgumentException('Not valid configuration.');
32
        }
33
34 29
        if (isset($config['migrations_directory'])) {
35 19
            $config['migrations_directory'] = $this->getDirectoryRelativeToFile($file, $config['migrations_directory']);
36
        }
37
38 29
        $this->setConfiguration($config);
39 26
    }
40
}
41