BaseValidator::getFromYaml()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 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