YamlLoader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processFile() 0 8 2
A load() 0 4 2
1
<?php
2
3
namespace Smart\EtlBundle\Loader;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
/**
8
 * Nicolas Bastien <[email protected]>
9
 */
10
class YamlLoader extends AbstractFileLoader implements LoaderInterface
11
{
12
    /**
13
     * @inheritDoc
14
     */
15
    protected $fileExtension = 'yml';
16
17
    /**
18
     * @inheritDoc
19
     */
20 1
    public function load(array $data)
21
    {
22 1
        foreach ($data as $filename => $fileData) {
23 1
            $this->processFile($filename, $fileData);
24
        }
25 1
    }
26
27
    /**
28
     * @param string $filename
29
     * @param array $data
30
     */
31 1
    protected function processFile($filename, $data)
32
    {
33 1
        $filepath = $this->getFolderToLoad() . DIRECTORY_SEPARATOR . $filename . '.' . $this->fileExtension;
34 1
        if (!is_dir(dirname($filepath))) {
35 1
            mkdir(dirname($filepath), 0700, true);
36
        }
37
38 1
        file_put_contents($filepath, Yaml::dump($data, 3));
39 1
    }
40
}
41