JsonReader::read()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Phiber\Util;
4
5
/**
6
 * Classe responsável por ler o arquivo de json especificado.
7
 *
8
 * @package util
9
 */
10
class JsonReader
11
{
12
    /**
13
     * Caminho absoluto para o local do arquivo.
14
     *
15
     * @var string
16
     */
17
    private $file;
18
19
    /**
20
     * JsonReader constructor.
21
     *
22
     * @param string $file
23
     */
24
    public function __construct($file)
25
    {
26
        $this->file = $file;
27
    }
28
29
    /**
30
     * Responsável por retornar o conteúdo do arquivo.
31
     *
32
     * @return array|boolean
33
     */
34
    public function read()
35
    {
36
37
        if ($content = file_get_contents($this->file)) {
38
            $read = json_decode($content);
39
            return $read;
40
        };
41
        return false;
42
    }
43
}
44