JsonMatrixParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A readAndParse() 0 6 1
A __construct() 0 6 1
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
}