protected function getDocFromJSON($json) { if (empty($json)) { $json = $this->downloadJSON(); } $doc = json_decode($json, true); if (json_last_error() > 0) { throw new \Exception('wrong json'); } return $doc; }