Ejemplo n.º 1
0
 /**
  * Creates an Uri object using the given URI components.
  *
  * Authority part will be overwritten by provided user info, host and port.
  *
  * @param string|null $scheme The URI scheme
  * @param string|null $authority The authority part
  * @param string|null $userInfo The user info part
  * @param string|null $host The host name
  * @param int|null $port The protocol port
  * @param string|null $path The path part
  * @param string|null $query The query part
  * @param string|null $fragment The fragment
  * @throws \Ableron\Core\Exception\SystemException
  * @return \Ableron\Lib\Net\Uri
  */
 public static function createFromComponents($scheme = null, $authority = null, $userInfo = null, $host = null, $port = null, $path = null, $query = null, $fragment = null)
 {
     try {
         $uri = new Uri();
         $uri->setScheme($scheme);
         $uri->setAuthority($authority);
         if ($userInfo !== null) {
             $uri->setUserInfo($userInfo);
         }
         if ($host !== null) {
             $uri->setHost($host);
         }
         if ($port !== null) {
             $uri->setPort($port);
         }
         $uri->setPath($path);
         $uri->setQuery($query);
         $uri->setFragment($fragment);
         return $uri;
     } catch (SystemException $e) {
         throw new SystemException('Unable to create Uri object', 0, E_USER_NOTICE, __FILE__, __LINE__, $e);
     }
 }
Ejemplo n.º 2
0
 /**
  * Tests whether setHost() works as expected.
  *
  * @dataProvider dataProviderTestSetHost
  * @return void
  */
 public function testSetHost($inputHost, $expectedHost)
 {
     $uri = new Uri();
     $uri->setHost($inputHost);
     $this->assertSame($expectedHost, $uri->getRawHost());
 }