Esempio n. 1
0
 /**
  * Gets the host.
  *
  * @return string The host
  */
 public function getHost()
 {
     if (!$this->host) {
         $this->host = UriSchemeFactory::make() . '://' . UriHostFactory::make();
     }
     return $this->host;
 }
Esempio n. 2
0
 public function testGetHost()
 {
     UriSchemeFactory::setForcedScheme('https');
     UriHostFactory::setForcedHost('foo.bar');
     $helper = new Url();
     $expected = 'https://foo.bar';
     $this->assertSame($expected, $helper->getHost());
 }
Esempio n. 3
0
 /**
  * Makes the instance of Es\Http\Uri.
  *
  * @param array $server Optional; null by default or empty array means
  *                      global $_SERVER. The source data
  *
  * @return \Es\Http\Uri The instance of Uri
  */
 public static function make(array $server = null)
 {
     $scheme = UriSchemeFactory::make($server);
     $host = UriHostFactory::make($server);
     $port = UriPortFactory::make($server);
     $path = UriPathFactory::make($server);
     $query = UriQueryFactory::make($server);
     $url = '';
     if ($host) {
         $url .= $scheme . '://' . $host . ':' . $port;
         $path = '/' . ltrim($path, '/');
     }
     $url .= $path;
     if ($query) {
         $url .= '?' . $query;
     }
     $uri = new Uri($url);
     if ($host) {
         return $uri;
     }
     return $uri->withScheme($scheme)->withPort($port);
 }
Esempio n. 4
0
 public function testRetrieveRetrievesNullOnFailure()
 {
     $server = ['foo' => 'bar'];
     $this->assertNull(UriHostFactory::retrieve($server));
 }