YamlFileLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 27
wmc 2
lcom 1
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A import() 0 6 1
A write() 0 6 1
1
<?php
2
/*
3
 * This file is part of the Borobudur-Config package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\Config\FileLoader;
12
13
use Symfony\Component\Yaml\Yaml;
14
15
/**
16
 * @author      Iqbal Maulana <[email protected]>
17
 * @created     8/12/15
18
 */
19
class YamlFileLoader extends AbstractFileLoader
20
{
21
    /**
22
     * @var array
23
     */
24
    protected $extensions = array('yml');
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function import(FileLocator $file)
30
    {
31
        $this->validateExtension($file->getExtension());
32
33
        return Yaml::parse($file->readFile());
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function write(array $configs, $file)
40
    {
41
        $this->validateExtension(pathinfo($file, PATHINFO_EXTENSION));
42
43
        $this->writeFile(Yaml::dump($configs, 10), $file);
44
    }
45
}
46