@param string $url    url to search for
@param string $format override format (defaults to one specified in config file)

@return mixed
516597
public function getRank($url, $format = null)
    {
        $arguments = [
            'url' => $url,
        ];
        $options = $this->getOptions($format)
            ->useSiteId(false)
            ->usePeriod(false)
            ->setArguments($arguments);

        return $this->request->send($options);
    }
452336
public function convertByUrl($url = '', $format = '', $outputFilename = '')
    {
        //check whether file is set or not
        if ($url == '')
            throw new Exception('Url not specified');

        $strURI = Product::$baseProductUri . '/pdf/convert?url=' . $url . '&format=' . $format;

        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'PUT', '', '');

        $v_output = Utils::validateOutput($responseStream);

        if ($v_output === '') {
            if ($this->saveFormat == 'html') {
                $saveFormat = 'zip';
            } else {
                $saveFormat = $this->saveFormat;
            }

            $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($outputFilename) . '.' . $format;
            Utils::saveFile($responseStream, $outputPath);
            return $outputPath;
        } else {
            return $v_output;
        }
    }
514654
protected static function parseUrl($url)
    {
        $url_parts = Utils::multibyteParseUrl($url);

        if (isset($url_parts['scheme'])) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            // Special handling for the streams.
            if ($locator->schemeExists($url_parts['scheme'])) {
                if (isset($url_parts['host'])) {
                    // Merge host and path into a path.
                    $url_parts['path'] = $url_parts['host'] . (isset($url_parts['path']) ? '/' . $url_parts['path'] : '');
                    unset($url_parts['host']);
                }

                $url_parts['stream'] = true;
            }
        }

        return $url_parts;
    }
140753
private function headersFromFormat($format)
	{
		$type = gettype($format);
		if($type === 'array')
		{
			$headers = $format;
		}
		else if($type === 'string')
		{
			$headers = array();
			switch ($format) 
			{
				case 'json':
					$contentType = 'application/json';
					break;
				case 'jsonp':
					$contentType = 'application/javascript';
					break;
				default:
					$contentType = 'text/plain';
					break;
			}
			$headers['Content-Type'] = $contentType;
		}
		return $headers;
	}
256220
public function getParser($format)
    {
        static $defaultParsers = [
            self::FORMAT_JSON => 'yii\httpclient\JsonParser',
            self::FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_XML => 'yii\httpclient\XmlParser',
        ];

        if (!isset($this->parsers[$format])) {
            if (!isset($defaultParsers[$format])) {
                throw new InvalidParamException("Unrecognized format '{$format}'");
            }
            $this->parsers[$format] = $defaultParsers[$format];
        }

        if (!is_object($this->parsers[$format])) {
            $this->parsers[$format] = Yii::createObject($this->parsers[$format]);
        }

        return $this->parsers[$format];
    }
877628
public function saveImage($url = '', $format = 'png')
    {
        $image        = DataRepository::getData('config_image');
        $defaultImage = $image['default_image'];
        try {
            Utils::debug('URL: ' . $url);
            Utils::debug('Format: ' . $format);
            try {
                // Xác định extention của file ảnh
                $info          = new \SplFileInfo($url);
                $fileExtension = $info->getExtension();
                $outputFormat  = !empty($fileExtension) ? $fileExtension : $format;
                Utils::debug('Output Format: ' . $outputFormat);
                // Quy định tên file ảnh sẽ lưu
                $fileName  = md5($url) . '.' . $outputFormat;
                $imageFile = $this->tmpPath . $fileName;
                $imageUrl  = $this->urlPath . $fileName;
                if (!file_exists($imageFile)) {
                    Utils::debug('Khong ton tai file: ' . $imageFile);
                    // Nếu như không tồn tại file ảnh -> sẽ tiến hành phân tích và cache file
                    // Xác định size ảnh
                    $imagine = new Imagine();
                    if (is_file($url)) {
                        Utils::debug('URL is File => ' . $url);
                        $image = $imagine->open($url);
                        $image->save($imageFile);
                    } else {
                        Utils::debug('URL is URL => ' . $url);
                        $getContent = Utils::getImageFromUrl($url);
                        Utils::debug('Data Content: ' . json_encode($getContent));
                        if (isset($getContent['content'])) {
                            $image = $imagine->load($getContent['content']);
                            Utils::debug('Load Content with CURL');
                        } else {
                            $image = $imagine->load($getContent);
                            Utils::debug('Load Content with file_get_content');
                        }
                        $result = $image->save($imageFile);
                        Utils::debug('Save Image Result: ' . json_encode($result));
                    }
                }
                $resultImage = trim($imageUrl);

                return $resultImage;
            }
            catch (RuntimeException $runtimeException) {
                if (function_exists('log_message')) {
                    $message = 'Runtime Error Code: ' . $runtimeException->getCode() . ' - File: ' . $runtimeException->getFile() . ' - Line: ' . $runtimeException->getLine() . ' - Message: ' . $runtimeException->getMessage();
                    log_message('error', $message);
                }

                return NULL;
            }
        }
        catch (\Exception $e) {
            if (function_exists('log_message')) {
                $message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
                log_message('error', $message);
            }

            return $defaultImage;
        }
    }
945875
public function generateUrl(string $format): string
    {
        switch ($format) {
            case self::FORMAT_EPS:
            case self::FORMAT_PNG:
            case self::FORMAT_SVG:
                break;
            default:
                throw new DiagramException(sprintf('Format "%s" not handled.', $format));
                break;
        }

        $puml    = $this->generatePuml();
        $encoded = encodep($puml);

        return sprintf(self::URL, $format, $encoded);
    }
1322307
public function setFormat($format)
    {
        if (!is_null($format)) {
            $this->format = $format;
            $this->useFormat(false);
        }

        return $this;
    }
1014334
protected function getFormatFromUrl($url)
    {
        $path = dirname($url);

        $formatParts = array_reverse(explode('/', $path));

        if (count($formatParts) < 2) {
            throw new ImageProxyInvalidUrl('No `format` was found in the url');
        }

        $format = $formatParts[1];

        return $format;
    }
462831
public function format($format = null)
    {
        if (!$format) {
            $format = $this->getFormat();
        }

        return parent::format($format ?: static::$toStringFormat);
    }
335087
public function emailFormat($format = null)
    {
        deprecationWarning('Email::emailFormat() is deprecated. Use Email::setEmailFormat() or Email::getEmailFormat() instead.');

        if ($format === null) {
            return $this->getEmailFormat();
        }

        return $this->setEmailFormat($format);
    }
727786
private function getUrlToOldApi($method, array $params, $format)
    {
        $queryString = sprintf(
            '?apikey=%s&format=%s&method=%s%s',
            $this->getApiKey(),
            $format,
            $method,
            $this->paramsQueryStringBuilder($params)
        );

        return sprintf(
            $this::API_URL,
            $this->getDc(),
            $this->getApiVersion(),
            $queryString
        );
    }
303390
function formatUrl($url)
    {
        if (! $this->isUrl($url)) {
            return null;
        }
        $url = trim($url);
        $url = str_replace(' ', '+', $url);
        $parse = parse_url($url);
        strtolower($parse['scheme']);
        strtolower($parse['host']);
        return $this->buildUrl($parse);
    }
457127
public function parseFromString($url) {
		$urlData = parse_url($url);
		
		if (isset($urlData['scheme'])) {
			$this->scheme = $urlData['scheme'];
		}
		
		if (isset($urlData['host'])) {
			$this->host = $urlData['host'];
		}
		
		if (isset($urlData['port'])) {
			$this->port = $urlData['port'];
		}
		
		if (isset($urlData['user'])) {
			$this->username = $urlData['user'];
		}
		
		if (isset($urlData['pass'])) {
			$this->password = $urlData['pass'];
		}
		
		if (isset($urlData['path'])) {
			$this->path = $urlData['path'];
		}
		
		if (isset($urlData['fragment'])) {
			$this->fragment = $urlData['fragment'];
		}
		
		if (isset($urlData['query'])) {
			$this->queryRaw = $urlData['query'];
			
			parse_str($urlData['query'], $this->query);
		}
		
		return $this;
	}
83533
public static function string($value, $format = null)
    {
        if (is_null($format)) {
            $format = '%s';
        }

        return sprintf($format, $value);
    }
397242
public function register($url, $format = 'json')
    {
        $this->setDataValue('url', $url);
        $this->setDataValue('format', strtoupper($format));

        $hooks = $this->getAllFromFlexibee();
        if (is_array($hooks) && count($hooks)) {
            foreach ($hooks as $hook) {
                if (is_array($hook) && array_key_exists('url', $hook)) {
                    if ($hook['url'] == $url) {
                        $this->addStatusMessage(_('Url allready registered'),
                            'warning');
                        return false;
                    }
                }
            }
        }
        $this->performRequest('?'.http_build_query($this->getData()), 'PUT',
            'xml');

        return $this->lastResponseCode === 200;
    }
1317925
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
        }

        $query = [];

        if (isset($components['query'])) {
            parse_str($components['query'], $query);
        }

        return new static(
            $components['scheme'] ?? null,
            $components['host'] ?? null,
            $components['port'] ?? null,
            $components['path'] ?? '',
            $query,
            $components['fragment'] ?? null,
            $preferredFormat
        );
    }