Completed
Push — master ( d88042...0c5536 )
by Nicolas
02:25 queued 48s
created

YamlLoader::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
nc 2
cc 2
nop 1
crap 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 1
    public function load(array $data)
16
    {
17 1
        foreach ($data as $filename => $fileData) {
18 1
            $this->processFile($filename, $fileData);
19
        }
20 1
    }
21
22
    /**
23
     * @param string $filename
24
     * @param array $data
25
     */
26 1
    protected function processFile($filename, $data)
27
    {
28 1
        $filepath = $this->getFolderToLoad() . DIRECTORY_SEPARATOR . $filename . '.' . $this->fileExtension;
29 1
        if (!is_dir(dirname($filepath))) {
30 1
            mkdir(dirname($filepath), 0700, true);
31
        }
32
33 1
        file_put_contents($filepath, Yaml::dump($data));
34 1
    }
35
}
36