Conditions | 5 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | 3 | public function __construct($path) |
|
35 | { |
||
36 | 3 | $this->path = $path; |
|
37 | 3 | if (!is_readable($path) || ($content = file_get_contents($path)) === false) { |
|
38 | 1 | $this->errorCode = self::ERROR_NO_READABLE; |
|
39 | 1 | return; |
|
40 | } |
||
41 | 2 | $this->data = json_decode($content, true); |
|
42 | 2 | if ($this->data === null && JSON_ERROR_NONE !== json_last_error()) { |
|
43 | 1 | $this->errorCode = self::ERROR_INVALID_JSON; |
|
44 | 1 | $this->errorMessage = json_last_error_msg(); |
|
45 | 1 | return; |
|
46 | } |
||
47 | 1 | $this->errorCode = self::NO_ERROR; |
|
48 | 1 | } |
|
49 | |||
83 |