BaseValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFromYaml() 0 14 3
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Validator;
4
5
use Symfony\Component\Yaml\Yaml;
6
use Admingenerator\GeneratorBundle\Generator\Generator;
7
8
class BaseValidator
9
{
10
    /**
11
     * @param string $yaml_path
12
     */
13
    protected function getFromYaml(Generator $generator, $yaml_path, $default = null)
14
    {
15
        $search_in = Yaml::parse(file_get_contents($generator->getGeneratorYml()));
16
17
        $yaml_path = explode('.',$yaml_path);
18
        foreach ($yaml_path as $key) {
19
            if (!isset($search_in[$key])) {
20
                return $default;
21
            }
22
            $search_in = $search_in[$key];
23
        }
24
25
        return $search_in;
26
    }
27
}
28