JsonMatrixParser::readAndParse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace GGGGino\WarehousePath\Parser;
4
5
use GGGGino\WarehousePath\PlacesCollector;
6
7
class JsonMatrixParser extends MatrixParser
8
{
9
    /**
10
     * @var string
11
     */
12
    private $pathFile;
13
14
    /**
15
     * @var array
16
     */
17
    private $jsonParsed;
18
19
    public function __construct(string $path, PlacesCollector $placeCollector)
20
    {
21
        $this->pathFile = $path;
22
        $this->jsonParsed = $this->readAndParse();
23
24
        parent::__construct($this->jsonParsed, $placeCollector);
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function readAndParse()
31
    {
32
        $string = file_get_contents($this->pathFile);
33
        $fileContent = json_decode($string, true);
34
35
        return $fileContent['warehouse'];
36
    }
37
}