コード例 #1
0
ファイル: Uri.php プロジェクト: ableron/ableron-core
 /**
  * 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);
     }
 }
コード例 #2
0
ファイル: UriTest.php プロジェクト: ableron/ableron-core
 /**
  * Tests whether setPath() works as expected.
  *
  * @dataProvider dataProviderTestSetPath
  * @return void
  */
 public function testSetPath($inputPath, $expectedPath)
 {
     $uri = new Uri();
     $uri->setPath($inputPath);
     $this->assertSame($expectedPath, $uri->getRawPath());
 }