Completed
Push — master ( 882947...a4a53d )
by Mike
13:52 queued 13:46
created

YamlConfiguration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 70 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 14
loc 20
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A doLoad() 14 14 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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