class JsonFileLoader extends FileLoader
{ protected function loadResource(string
$resource): array
{ $messages =
[];
if ($data =
file_get_contents($resource)) { $messages =
json_decode($data, true
);
if (0 <
$errorCode =
json_last_error()) { throw new InvalidResourceException('Error parsing JSON: '.
$this->
getJSONErrorMessage($errorCode));
} } return $messages;
} /**
* Translates JSON_ERROR_* constant into meaningful message.
*/
private function getJSONErrorMessage(int
$errorCode): string
{