public static function load()

in app/classes/ReleaseInsights/Json.php [75:101]


    public static function load(string $url, int $ttl = 0): array
    {
        if (! $data = Cache::getKey($url, $ttl)) {
            $data = Utils::getFile($url);

            // Error fetching external data, don't cache. Safety net
            // @codeCoverageIgnoreStart
            if ($data === false) {
                return ['error' => 'URL triggered an error'];
            }
            // @codeCoverageIgnoreEnd

            // No data returned, bug or incorrect data, don't cache.
            if (empty($data)) {
                return ['error' => 'URL provided no data'];
            }

            // Invalid Json, don't cache.
            if (! json_validate($data)) {
                return ['error' => 'Invalid JSON source'];
            }

            Cache::setKey($url, $data, $ttl);
        }

        return self::toArray($data);
    }