getArrayFromJson($content); } /** * Fetch metadata information from an URL * @param string $url URL linking to a metadata.json file * @return array The metadata fetched from the file */ public function fetchFromUrl($url, $type = 'Plugin') { $contents = qa_retrieve_url($url); $metadata = $this->getArrayFromJson($contents); // fall back to old metadata format if (empty($metadata)) { $metadata = qa_addon_metadata($contents, $type); } return $metadata; } /** * Return an array from a JSON string * @param mixed $json The JSON string to turn into an array * @return array Always return an array containing the decoded JSON or an empty array in case the * $json parameter is not a valid JSON string */ private function getArrayFromJson($json) { $result = json_decode($json, true); return is_array($result) ? $result : array(); } }