/** * @param IUrl $destination */ public function setDestination(IUrl $destination) { $this->destination = $destination; $this->getHeaders()->set('location', $destination->toString()); }
/** * @param IUrl $url * @param array $subdomains * * @return bool */ public function compareUrlToSubdomains(IUrl $url, array $subdomains) { if (count($subdomains) == 0) { return true; } return array_contains($subdomains, $url->getSubdomain()); }
private function check_url(IUrl $url) { $this->assertEquals('http', $url->getProtocol()); $this->assertEquals('name', $url->getUsername()); $this->assertEquals('pass', $url->getPassword()); $this->assertEquals('just.an.example.com', $url->getHost()); $this->assertEquals('example', $url->getDomain()); $this->assertEquals('com', $url->getTLD()); $this->assertEquals('just.an', $url->getSubdomain()); $this->assertEquals('80', $url->getPort()); $this->assertEquals('/products', $url->getPath()); $this->assertEquals('sku=1234', $url->getQuery()->toString()); $this->assertEquals('price', $url->getFragment()); }
/** * @param IRoute[] $routes * @param $method * @param IUrl $url * * @return IRoute|null */ protected function matchRoute(array $routes, $method, IUrl $url) { foreach ($routes as $route) { if ($this->compareRouteToMethod($route, $method) && $this->getUrlMatcher()->match($route->getPath(), $url->getPath()) && $this->getRestrictionsMatcher()->match($url)) { $parameters = $this->getUrlMatcher()->parse($route->getPath(), $url->getPath()); $route->setParameters($parameters->toArray()); return $route; } } return null; }