YamlStorage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 13 3
1
<?php
2
/**
3
 * @author Serhii Nekhaienko <[email protected]>
4
 * @license GPL
5
 * @copyright Serhii Nekhaienko &copy 2018
6
 * @version 4.0.0
7
 * @project endorphin-studio/browser-detector
8
 */
9
10
namespace EndorphinStudio\Detector\Storage;
11
12
use Symfony\Component\Yaml\Parser;
13
use Symfony\Component\Yaml\Yaml;
14
15
/**
16
 * Class YamlStorage
17
 * Provide data files reader from yaml files
18
 * Use symfony\yaml component
19
 * @package EndorphinStudio\Detector\Storage
20
 */
21
class YamlStorage extends FileStorage implements StorageInterface
22
{
23
    /**
24
     * Get array of Data (patterns and etc.)
25
     * @return array array of data
26
     */
27
    public function getConfig(): array
28
    {
29
        if (empty($this->config)) {
30
            $yamlParser = new Parser();
31
            $files = $this->getFileNames();
32
            $config = [];
33
            foreach ($files as $file) {
34
                $fileConfig = $yamlParser->parseFile($file);
35
                $config = \array_merge($config, $fileConfig);
36
            }
37
            $this->config = $config;
38
        }
39
        return $this->config;
40
    }
41
}