IniFile::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace ConfigTree\FileParsing\Formats;
3
4
use ConfigTree\FileParsing\ArrayableFile;
5
use ConfigTree\FileParsing\Reading\FileContentsRetriever;
6
7 View Code Duplication
class IniFile implements ArrayableFile
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /** @var string */
10
    private $path;
11
12
    /** @var FileContentsRetriever */
13
    private $fileContentsRetriever;
14
15
    public function __construct(string $path, FileContentsRetriever $fileContentsRetriever)
16
    {
17
        $this->path = $path;
18
        $this->fileContentsRetriever = $fileContentsRetriever;
19
    }
20
21
    public function toArray() : array
22
    {
23
        $fileContents = $this->fileContentsRetriever->fileGetContents($this->path);
24
        return parse_ini_string($fileContents);
25
    }
26
}
27