Locate the template

@param   string  $url The template url
@throws InvalidArgumentException If the template could not be located
@return string   The template real path
160275
protected function _locate($url)
    {
        //Locate the template
        if (!$file = $this->getObject('template.locator.factory')->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        return $file;
    }
1373528
public function getLayout($url)
    {
        $engines = $this->getObject('template.engine.factory')->getFileTypes();
        $parts   = explode('.', $url);

        if(in_array(end($parts), $engines))
        {
            $type  =  array_pop($parts);
            $format = array_pop($parts);
        }
        else $format = array_pop($parts);

        return $this->getIdentifier(implode('.', $parts));
    }
298147
public function path($url) {
        $prefix = $this->config['url_prefix'];

        // If the url_prefix is absolute-path style but the url isn't, get only the
        // path from the URL before comparing against the prefix.
        if (preg_match('#^/#', $prefix) && preg_match('#^http#', $url)) {
            $url = parse_url($url, PHP_URL_PATH);
        }

        // Trim the prefix from the URL
        return substr($url, strlen($prefix));
    }
1119767
public static function getPort(string $url)
    {
        $url = UrlHelper::validateUrl($url);

        $port = parse_url($url, PHP_URL_PORT);
        if ($port === false) {
            throw new InvalidArgumentException("Could not determine port, url seems to be invalid: $url");
        }

        return $port;
    }
271392
public static function get_server_location( $url ) {
		// if we're already an absolute dir, just return.
		if ( 0 === strpos($url, ABSPATH) ) {
			return $url;
		}
		// otherwise, analyze URL then build mapping path
		$au = self::analyze_url($url);
		$result = self::_get_file_path($au['base'], $au['subdir'], $au['basename']);
		return $result;
	}
142687
public function addImageFromUrl($url) {
        if (is_string($url)) {
            // URL specified as a string. Create a URL instance
            $url = GuzzleUrl::factory($url);
        }

        if (!($url instanceof GuzzleUrl)) {
            // Invalid argument
            throw new InvalidArgumentException(
                'Parameter must be a string or an instance of Guzzle\Http\Url'
            );
        }

        if (!$url->getScheme()) {
            throw new InvalidArgumentException('URL is missing scheme: ' . (string) $url);
        }

        // Fetch the image we want to add
        $image = (string) $this->get($url)->send()->getBody();

        return $this->addImageFromString($image);
    }
447688
protected function _load($url)
    {
        $file = $this->_locate($url);
        $type = pathinfo($file, PATHINFO_EXTENSION);

        if(in_array($type, $this->getFileTypes()))
        {
            if(!$this->_source = file_get_contents($file)) {
                throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
            }
        }
        else $this->_source = $this->getTemplate()->loadFile($file)->render($this->getData());

        return $this->_source;
    }
876457
protected function fetchEndpointForUrl($url)
    {
        $client = new Client($url);

        $body = $client->send();

        $regexp = str_replace(
            '@formats@',
            implode('|', $this->supportedFormats),
            self::LINK_REGEXP
        );

        if (!preg_match_all($regexp, $body, $matches, PREG_SET_ORDER)) {
            throw new \InvalidArgumentException('No valid oEmbed links found on page.');
        }

        foreach ($matches as $match) {
            if ($match['Format'] === $this->preferredFormat) {
                return $this->extractEndpointFromAttributes($match['Attributes']);
            }
        }

        return $this->extractEndpointFromAttributes($match['Attributes']);
    }
804930
public function find($template)
    {
        is_array($template) and $template = array_filter($template, 'is_string');
        if ((! is_string($template) && ! is_array($template)) || empty($template)) {
            throw new InvalidArgumentException(
                'Template name must be a string or an array of strings.'
            );
        }
        if (is_array($template)) {
            return $this->findMany($template);
        }
        $parse = $this->parseName($template);
        if ($parse['dir']) {
            return $this->findInDir($parse['dir'], $parse['file']);
        }

        return $parse['file'] ? $this->scanFor($parse['file']) : false;
    }
981034
protected function urlParts(string $url)
    {
        if (false === filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
            return false;
        }
        return parse_url($url) ?: false;
    }
1037414
public function tokenizeUrl($url)
	{
		if(!is_file($url))
		{
			throw new \RuntimeException(sprintf('URL does not point to a valid file: "%s"', $url));
		}
		
		$source = @file_get_contents($url);
		
		if($source === false)
		{
			// @codeCoverageIgnoreStart
			throw new \RuntimeException(sprintf('Unable to tokenize contents loaded from: "%s"', $url));
			// @codeCoverageIgnoreEnd
		}
		
		return $this->tokenize($source);
	}
439810
public function relative($url)
    {
        if (!$url || $url == '/') {
            return '.';
        }

        if (strpos($url, '..') !== false) {
            throw new InvalidArgumentException('Double dots in paths are not allowed');
        }

        $baseUrl = $this->getBaseUrl();

        if ($baseUrl && strpos($url, $baseUrl) === 0) {
            return trim(str_replace($baseUrl, '', $url), '/');
        }

        if ($this->startsWithBasePath($url) || !$this->checkFilesystem) {
            return trim(str_replace($this->basePath, '', $url), '/');
        }

        return static::getRelativePath($this->basePath, $url);
    }
978732
public function locate($url)
    {
        if(!isset($this->_locations[$url]))
        {
            $layout = $this->getLayout($url);

            $info = array(
                'url'      => $url,
                'domain'   => $layout->getDomain(),
                'package'  => $layout->getPackage(),
                'path'     => $layout->getPath(),
            );

            $info += $this->parseIdentifier($url);

            $this->_locations[$url] = $this->find($info);
        }

        return $this->_locations[$url];
    }
756301
public function setUrl(string $url) : Request
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new \InvalidArgumentException('The URL provided is not valid.');
        }

        if (! isset($components['scheme'])) {
            throw new \InvalidArgumentException('The URL must have a scheme.');
        }

        $scheme = strtolower($components['scheme']);

        if ($scheme !== 'http' && $scheme !== 'https') {
            throw new \InvalidArgumentException(sprintf('The URL scheme "%s" is not acceptable.', $scheme));
        }

        $isSecure = ($scheme === 'https');

        if (! isset($components['host'])) {
            throw new \InvalidArgumentException('The URL must have a host name.');
        }

        $host = $components['host'];

        if (isset($components['port'])) {
            $port = $components['port'];
            $hostHeader = $host . ':' . $port;
        } else {
            $port = ($isSecure ? 443 : 80);
            $hostHeader = $host;
        }

        $this->path = isset($components['path']) ? $components['path'] : '/';
        $requestUri = $this->path;

        if (isset($components['query'])) {
            $this->queryString = $components['query'];
            parse_str($this->queryString, $this->query);
            $requestUri .= '?' . $this->queryString;
        } else {
            $this->queryString = '';
            $this->query = [];
        }

        $this->setHeader('Host', $hostHeader);

        $this->host = $host;
        $this->port = $port;
        $this->isSecure = $isSecure;
        $this->requestUri = $requestUri;

        return $this;
    }
1162326
public function setUrl($url)
    {
        if (is_string($url)) {
            $this->url = $url;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($url) . "' for argument 'url' given. String expected."
            );
        }
    }
1242493
public static function get_template( $url ) {
		if ( ! $url ) {
			return;
		}

		$cache = Cache::get( $url );

		return static::_strip_newlines(
			! empty( $cache['title'] )
				? static::get_blog_card_template( $url, $cache )
				: static::get_url_template( $url )
		);
	}
1188850
public function findFilename($name) {
     	$logicalName = (string) $name;
     	if(isset($this->cache[$logicalName])) {
     		return $this->cache[$logicalName];
     	}

     	try {
     		$template = $this->parser->parse($name);
     		$file = $this->locator->locate($template);
     	} catch (\Exception $e) {
     		throw new \InvalidArgumentException(sprintf('Unable to find template "%s".', $logicalName));
     	}

     	return $this->cache[$logicalName] = $file;
     }