@param string $uri

@return Response
551428
public function get(string $uri)
    {
        $request = $this->getRequest($uri);

        return $this->send($request);
    }
1156404
private function prepareUriForLocalhostAccess($uri)
    {
        $public = 'public';
        $index = 'index.php';

        if (strpos($uri, $index)) {
            return substr($uri, strpos($uri, $index) + strlen($index));
        } elseif (strpos($uri, $public)) {
            return substr($uri, strpos($uri, $public) + strlen($public));
        }

        return false;
    }
551362
public static function check($uri)
  {
    try
    {
      $uri = new self(strval($uri));
    }
    catch(\Exception $e)
    {
      return FALSE;
    }

    return $uri->valid();
  }
441298
static protected function curl ( $uri )
	{
		$ch = curl_init();

		curl_setopt($ch, CURLOPT_HTTPHEADER,	 array('Accept: application/xrds+xml, */*;q=0.1'));
		curl_setopt($ch, CURLOPT_USERAGENT,		 'anyMeta/OAuth 1.0 - (OAuth Discovery $LastChangedRevision: 45 $)');
		curl_setopt($ch, CURLOPT_URL, 			 $uri);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HEADER, 		 true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 		 30);

		$txt = curl_exec($ch);
		curl_close($ch);

		// Tell the logger what we requested and what we received back
		$data = "GET $uri";
		OAuthRequestLogger::setSent($data, "");
		OAuthRequestLogger::setReceived($txt);

		return $txt;
	}
899669
protected function parseUrl($uri)
    {
        $parsedUrl = parse_url($uri);

        return [
            isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : '',
            isset($parsedUrl['host']) ? $parsedUrl['host'] : '',
            isset($parsedUrl['port']) ? $parsedUrl['port'] : null,
            isset($parsedUrl['path']) ? $parsedUrl['path'] : '/',
            isset($parsedUrl['query']) ? $parsedUrl['query'] : '',
            isset($parsedUrl['fragment']) ? $parsedUrl['fragment'] : '',
            isset($parsedUrl['user']) ? $parsedUrl['user'] : '',
            isset($parsedUrl['pass']) ? $parsedUrl['pass'] : ''
        ];
    }
1196836
public function handle($uri = null)
    {
        $method = $this->prepareMethodName();

        if (empty($uri)) {
            $uri = $this->getRewriteUri();
        }

        $uri = trim($uri, '/');

        // remove empty cells
        $parts = [];
        foreach (explode('/', $uri) as $p) {
            if (trim($p) !== '') {
                $parts[] = $p;
            }
        }

        $this->extractLanguage($parts);

        // check if it is REST or not, then do what is required
        $this->prepareRestRequest($parts);

        // Cleaning route parts & Rebase array keys
        $parts[] = strtolower(self::DEFAULT_ACTION);
        $camelizedParts = $parts;

        $camelizedParts = array_values(array_map('Rad\Utility\Inflection::camelize', $camelizedParts));
        $bundle = reset($camelizedParts);
        $bundles = array_intersect([$bundle, 'App'], Bundles::getLoaded());

        foreach ($bundles as $bundleName) {
            // reset manipulation parameters
            $dummyCamelizedParts = $camelizedParts;
            $dummyParts = $parts;

            if ($bundleName === 'App' && $dummyCamelizedParts[0] != 'App') {
                array_unshift($dummyParts, $bundleName);
                array_unshift($dummyCamelizedParts, $bundleName);
            } else {
                // get bundle namespace instead of its name
                array_shift($dummyCamelizedParts);
                array_unshift($dummyCamelizedParts, trim(Bundles::getNamespace($bundleName), '\\'));
            }

            // add "Action" to array as second param
            array_splice($dummyCamelizedParts, 1, 0, 'Action');

            $this->routingPhase = self::ROUTING_PHASE_ACTION;
            /**
             * routingPhase is sequence of three phases, in the following order
             * 1- direct call of action
             * 2- direct call of method
             * 3- direct call of index action
             */

            // Continue searching till you found any matching
            // Or you have at least three elements in array (Bundle, "Action", Action)
            while (count($dummyCamelizedParts) >= 3) {
                $actionNamespace = implode('\\', $dummyCamelizedParts) . 'Action';

                if (class_exists($actionNamespace)) {
                    $this->finalizeRouterArguments(
                        $dummyParts,
                        $dummyCamelizedParts,
                        $actionNamespace,
                        $bundleName,
                        $method
                    );

                    break 2;
                }

                array_pop($dummyCamelizedParts);

                // change router for some other default paths
                switch ($this->routingPhase) {
                    case self::ROUTING_PHASE_INDEX:
                        $this->routingPhase = self::ROUTING_PHASE_ACTION;
                        break;
                    case self::ROUTING_PHASE_METHOD:
                        $dummyCamelizedParts[] = self::DEFAULT_ACTION;
                        $this->routingPhase--;
                        break;
                    case self::ROUTING_PHASE_ACTION:
                        $dummyCamelizedParts[] = $method;
                        $this->routingPhase--;
                        break;
                }
            }
        }
    }
1328703
public function options(string $uri)
    {
        $request = $this->getRequest($uri)
            ->setMethod('OPTIONS');

        return $this->send($request);
    }
644974
public function prepareHttp(string $uri)
    {
        $this->uri = $uri;

        // first, check the URI for duplicate slashes - they are not allowed
        // if you must pass duplicate slashes in URL, then urlencode them
        $redirect = null;
        if (strpos($this->uri, '//') !== false) {
            $redirect = str_replace('//', '/', $this->uri);
        }

        if (strlen($this->uri) > 1 && substr($this->uri, -1) == '/') {
            // ending slash is not needed, unless you have a namespace
            // if you need to pass slash on the end of URI, then urlencode it
            if ($redirect === null) {
                $redirect = substr($this->uri, 0, -1);
            } else {
                $redirect = substr($redirect, 0, -1);
            }
        }

        if ($redirect !== null) {
            header('Location: ' . Application::getDomainWithSchema() . $redirect);
            exit(0);
        }

        $questionPos = strpos($this->uri, '?');
        if ($questionPos !== false) {
            $this->uri = substr($this->uri, 0, $questionPos);
        }

        $ds = DS;

        $this->uri = explode('/', $this->uri);
        if (!isset($this->uri[1])) {
            $this->uri[1] = '';
        }

        // There are two possible scenarios:
        // 1. The first part of URL leads to the module controller
        // 2. The first part of URL leads to the default controller

        if ($this->uri[1] == '') {
            $this->controllerUrl = 'index';
            $this->controllerClass = 'IndexController';
        } else {
            $this->controllerUrl = strtolower($this->uri[1]);
            $this->controllerClass = str_replace(' ', '', ucwords(str_replace(['-', '.'], ' ', $this->controllerUrl))) . 'Controller';
        }

        // Now we have the controller class name detected, but, should it be
        // taken from module or from default controllers?

        $moduleDir = Application::getModulePath($this->controllerUrl);

        if (is_dir($moduleDir)) {
            Application::setCurrentModule($this->controllerUrl);

            // ok, it is a module with module/controller/action path
            $moduleUrl = $this->controllerUrl;
            $this->moduleUrl = $moduleUrl;

            if (isset($this->uri[2]) && $this->uri[2] != '') {
                $this->controllerUrl = strtolower($this->uri[2]);
                $this->controllerClass = str_replace(' ', '', ucwords(str_replace(['-', '.'], ' ', $this->controllerUrl))) . 'Controller';
            } else {
                $this->controllerUrl = 'index';
                $this->controllerClass = 'IndexController';
            }

            $this->controllerPath = "{$moduleDir}controllers{$ds}{$this->controllerClass}.php";
            $mainControllerExists = true;

            if (!is_file($this->controllerPath)) {
                // lets try with default controller when requested one is not here
                $this->controllerPath = Application::getModulePath($moduleUrl) . "controllers{$ds}IndexController.php";

                if (!is_file($this->controllerPath)) {
                    // Even IndexController is missing. Can not resolve that.
                    throw new NotFoundException("Can not find {$this->controllerClass} nor IndexController in {$moduleDir}{$ds}controllers");
                }

                $mainControllerExists = false;
                $this->controllerClass = 'IndexController';
            }

            if ($mainControllerExists) {
                if (!isset($this->uri[3]) || $this->uri[3] == '') {
                    $this->actionUrl = 'index';
                    $this->actionMethod = 'index';
                } else {
                    $this->actionUrl = strtolower($this->uri[3]);
                    $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                    $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                    $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
                }
            } else if (isset($this->uri[2]) && $this->uri[2] != '') {
                $this->actionUrl = strtolower($this->uri[2]);
                $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
            } else {
                $this->actionUrl = 'index';
                $this->actionMethod = 'index';
            }

        } else {

            // ok, it is the default controller/action
            $this->controllerPath = Application::getApplicationPath("controllers{$ds}{$this->controllerClass}.php");

            $mainControllerExists = true;

            if (!is_file($this->controllerPath)) {
                $this->controllerPath = Application::getApplicationPath("controllers{$ds}IndexController.php");

                if (!is_file($this->controllerPath)) {
                    // Even IndexController is missing. Can not resolve that.
                    throw new NotFoundException("Can not find {$this->controllerClass} nor IndexController in " . Application::getApplicationPath('controllers'));
                }

                $mainControllerExists = false;
                $this->controllerClass = 'IndexController';
            }

            if ($mainControllerExists) {
                if (!isset($this->uri[2]) || $this->uri[2] == '') {
                    $this->actionUrl = 'index';
                    $this->actionMethod = 'index';
                } else {
                    $this->actionUrl = strtolower($this->uri[2]);
                    $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                    $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                    $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
                }
            } else {
                $this->actionUrl = strtolower($this->uri[1]);
                $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
            }

            // and now, configure the include paths according to the case
            $basePath = Application::getApplicationPath();
            Application::addIncludePath($basePath . 'controllers',    // so you can extend abstract controllers in the same directory if needed,
              $basePath . 'library'      // the place where you can define your own classes and methods
            );
        }

        $this->isAjax = (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'],
              'application/json') !== false);

        $controllerClassName = $this->getControllerClass();

        if (!class_exists($controllerClassName)) {
            throw new Exception("Can not find class {$controllerClassName}; current include path is:\n" . get_include_path());
        }

        $controllerInstance = new $controllerClassName();

        $alwaysRestful = (isset($this->config['always_restful'])) && $this->config['always_restful'] === true;

        if ($alwaysRestful || (property_exists($controllerInstance, 'restful') && $controllerInstance::$restful === true)) {
            // it is restful
            $this->actionMethod = strtolower($_SERVER['REQUEST_METHOD']) . ucfirst($this->actionMethod);

        } else if ($this->isAjax) {
            $this->actionMethod .= 'Ajax';

        } else {
            $this->actionMethod .= 'Action';

        }

        $this->controllerInstance = $controllerInstance;
    }
1162095
protected function respond($url)
    {
        $response = $this->request($url);
        $response = $this->parse($response);

        return $this->create($response);
    }
1269349
protected function createWhenUri($uri)
    {
        $when = static::$firing['when'];

        if (substr($when, -1) !== '/') {
            $when .= '/';
        }

        if(substr($uri, 0,1) === '/'){
            $uri = substr($uri, 1, strlen($uri));
        }

        return $when.$uri;
    }
1149268
public function post($uri, array $params = array())
    {

        $ch = $this->initCurlHandler($uri);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

        return $this->makeRequest($ch);

    }
476991
public function delete(string $uri)
    {
        $request = $this->getRequest($uri)
            ->setMethod('DELETE');

        return $this->send($request);
    }
368241
public static function extract_query_from_uri($uri)
	{
		$uri_query_str = parse_url($uri, PHP_URL_QUERY);

		if ( ! $uri_query_str)
		{
			return array();
		}

		parse_str($uri_query_str, $uri_query);

		return $uri_query;
	}
314284
protected function fromString($uri)
    {
        if (empty($uri)) {
            return $this;
        }

        $this->fromArray(parse_url($uri));

        return $this;
    }
763681
public function retrieve($uri)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $uri);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));

        $response = curl_exec($ch);
        if (false === $response) {
            throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
        }

        $this->fetchMessageBody($response);
        $this->fetchContentType($response);

        curl_close($ch);

        return $this->messageBody;
    }
284519
protected function processUri($uri)
    {
        return preg_replace_callback('#\{([a-zA-Z0-9_,]*)\}#i', function ($matches) {
            return isset($this->tokens[$matches[1]]) ? $this->tokens[$matches[1]] : '';
        }, $uri);
    }
910074
public static function getDomain($uri)
    {
        $returnValue = parse_url($uri, PHP_URL_HOST);
        if (empty($returnValue)) {
            return null;
        }

        return $returnValue;
    }