/** * Download an url and return or store contents. * * @param string $url * @param bool $file * * @return bool|null|string * @throws \Exception */ public static function download($url, $file = false) { if (Runtime::isCurlEnabled()) { return static::curlDownload($url, $file); } else { if (Runtime::isAllowUrlFopenEnabled()) { return static::fgetDownload($url, $file); } else { throw new \RuntimeException('No download mechanism available'); } } }