YamlFile   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A toArray() 0 5 1
1
<?php
2
namespace ConfigTree\FileParsing\Formats;
3
4
use ConfigTree\FileParsing\ArrayableFile;
5
use ConfigTree\FileParsing\Reading\FileContentsRetriever;
6
use Symfony\Component\Yaml\Parser as YamlParser;
7
8
class YamlFile implements ArrayableFile
9
{
10
    /** @var string */
11
    private $path;
12
13
    /** @var FileContentsRetriever */
14
    private $fileContentsRetriever;
15
16
    /** @var YamlParser */
17
    private $yamlParser;
18
19
    public function __construct(string $path, FileContentsRetriever $fileContentsRetriever, YamlParser $yamlParser)
20
    {
21
        $this->path                  = $path;
22
        $this->fileContentsRetriever = $fileContentsRetriever;
23
        $this->yamlParser            = $yamlParser;
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function toArray() : array
30
    {
31
        $fileContents = $this->fileContentsRetriever->fileGetContents($this->path);
32
        return $this->yamlParser->parse($fileContents);
33
    }
34
}
35