| @@ 51-60 (lines=10) @@ | ||
| 48 | * @return array |
|
| 49 | * @throws \NeedleProject\FileIo\Exception\ContentException |
|
| 50 | */ |
|
| 51 | public function getArray(): array |
|
| 52 | { |
|
| 53 | $content = json_decode($this->content, true); |
|
| 54 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 55 | throw new ContentException( |
|
| 56 | sprintf("Could not decode content, got %s", json_last_error_msg()) |
|
| 57 | ); |
|
| 58 | } |
|
| 59 | return $content; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @return \stdClass |
|
| @@ 66-75 (lines=10) @@ | ||
| 63 | * @return \stdClass |
|
| 64 | * @throws \NeedleProject\FileIo\Exception\ContentException |
|
| 65 | */ |
|
| 66 | public function getObject(): \stdClass |
|
| 67 | { |
|
| 68 | $content = json_decode($this->content); |
|
| 69 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 70 | throw new ContentException( |
|
| 71 | sprintf("Could not decode content, got %s", json_last_error_msg()) |
|
| 72 | ); |
|
| 73 | } |
|
| 74 | return $content; |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||