当前位置: 首页>>代码示例>>PHP>>正文


PHP UriInterface::getAuthority方法代码示例

本文整理汇总了PHP中Psr\Http\Message\UriInterface::getAuthority方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::getAuthority方法的具体用法?PHP UriInterface::getAuthority怎么用?PHP UriInterface::getAuthority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\UriInterface的用法示例。


在下文中一共展示了UriInterface::getAuthority方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * @param LeagueUriInterface|UriInterface $relative
  *
  * @return LeagueUriInterface|UriInterface
  */
 protected function generate($relative)
 {
     $scheme = $relative->getScheme();
     if (!empty($scheme) && $scheme != $this->uri->getScheme()) {
         return $relative;
     }
     if (!empty($relative->getAuthority())) {
         return $relative->withScheme($this->uri->getScheme());
     }
     return $this->resolveRelative($relative)->withFragment($relative->getFragment());
 }
开发者ID:burguin,项目名称:test02,代码行数:16,代码来源:Resolve.php

示例2: resolve

 /**
  * Resolve a base URI with a relative URI and return a new URI.
  *
  * @param UriInterface             $base Base URI
  * @param null|string|UriInterface $rel  Relative URI
  *
  * @throws \InvalidArgumentException
  *
  * @return UriInterface
  */
 public static function resolve(UriInterface $base, $rel = null)
 {
     if ($rel === null || $rel === '') {
         return $base;
     }
     if (!$rel instanceof UriInterface) {
         $rel = new self($rel);
     }
     // Return the relative uri as-is if it has a scheme.
     if ($rel->getScheme()) {
         return $rel->withPath(static::removeDotSegments($rel->getPath()));
     }
     $relParts = ['scheme' => $rel->getScheme(), 'authority' => $rel->getAuthority(), 'path' => $rel->getPath(), 'query' => $rel->getQuery(), 'fragment' => $rel->getFragment()];
     $parts = ['scheme' => $base->getScheme(), 'authority' => $base->getAuthority(), 'path' => $base->getPath(), 'query' => $base->getQuery(), 'fragment' => $base->getFragment()];
     if (!empty($relParts['path'])) {
         if (strpos($relParts['path'], '/') === 0) {
             $parts['path'] = self::removeDotSegments($relParts['path']);
             $parts['query'] = $relParts['query'];
             $parts['fragment'] = $relParts['fragment'];
         } else {
             $mergedPath = substr($parts['path'], 0, strrpos($parts['path'], '/') + 1);
             $parts['path'] = self::removeDotSegments($mergedPath . $relParts['path']);
             $parts['query'] = $relParts['query'];
             $parts['fragment'] = $relParts['fragment'];
         }
     } elseif (!empty($relParts['query'])) {
         $parts['query'] = $relParts['query'];
     } elseif ($relParts['fragment'] !== null) {
         $parts['fragment'] = $relParts['fragment'];
     }
     return new self(static::createUriString($parts['scheme'], $parts['authority'], $parts['path'], $parts['query'], $parts['fragment']));
 }
开发者ID:webservices-nl,项目名称:common,代码行数:42,代码来源:Uri.php

示例3: getRelativePath

 private static function getRelativePath(UriInterface $base, UriInterface $target)
 {
     $sourceSegments = explode('/', $base->getPath());
     $targetSegments = explode('/', $target->getPath());
     array_pop($sourceSegments);
     $targetLastSegment = array_pop($targetSegments);
     foreach ($sourceSegments as $i => $segment) {
         if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) {
             unset($sourceSegments[$i], $targetSegments[$i]);
         } else {
             break;
         }
     }
     $targetSegments[] = $targetLastSegment;
     $relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments);
     // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
     // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
     // as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
     if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) {
         $relativePath = "./{$relativePath}";
     } elseif ('/' === $relativePath[0]) {
         if ($base->getAuthority() != '' && $base->getPath() === '') {
             // In this case an extra slash is added by resolve() automatically. So we must not add one here.
             $relativePath = ".{$relativePath}";
         } else {
             $relativePath = "./{$relativePath}";
         }
     }
     return $relativePath;
 }
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:30,代码来源:UriResolver.php

示例4: isRelativePathReference

 /**
  * Whether the URI is a relative-path reference.
  *
  * A relative reference that does not begin with a slash character is termed a relative-path reference.
  *
  * @param UriInterface $uri
  *
  * @return bool
  * @link https://tools.ietf.org/html/rfc3986#section-4.2
  */
 public static function isRelativePathReference(UriInterface $uri)
 {
     return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
 }
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:14,代码来源:Uri.php

示例5: resolve

 /**
  * Resolve a base URI with a relative URI and return a new URI.
  *
  * @param UriInterface        $base Base URI
  * @param string|UriInterface $rel  Relative URI
  *
  * @return UriInterface
  * @link http://tools.ietf.org/html/rfc3986#section-5.2
  */
 public static function resolve(UriInterface $base, $rel)
 {
     if (!$rel instanceof UriInterface) {
         $rel = new self($rel);
     }
     if ((string) $rel === '') {
         // we can simply return the same base URI instance for this same-document reference
         return $base;
     }
     if ($rel->getScheme() != '') {
         return $rel->withPath(self::removeDotSegments($rel->getPath()));
     }
     if ($rel->getAuthority() != '') {
         $targetAuthority = $rel->getAuthority();
         $targetPath = self::removeDotSegments($rel->getPath());
         $targetQuery = $rel->getQuery();
     } else {
         $targetAuthority = $base->getAuthority();
         if ($rel->getPath() === '') {
             $targetPath = $base->getPath();
             $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
         } else {
             if ($rel->getPath()[0] === '/') {
                 $targetPath = $rel->getPath();
             } else {
                 if ($targetAuthority != '' && $base->getPath() === '') {
                     $targetPath = '/' . $rel->getPath();
                 } else {
                     $lastSlashPos = strrpos($base->getPath(), '/');
                     if ($lastSlashPos === false) {
                         $targetPath = $rel->getPath();
                     } else {
                         $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
                     }
                 }
             }
             $targetPath = self::removeDotSegments($targetPath);
             $targetQuery = $rel->getQuery();
         }
     }
     return new self(self::createUriString($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:51,代码来源:Uri.php

示例6: runMatches

 protected function runMatches(UriInterface $uri)
 {
     return $uri->getAuthority() == $this->expected;
 }
开发者ID:oscarotero,项目名称:psr7-unitesting,代码行数:4,代码来源:Authority.php

示例7: s3MVC_UriToString

/**
 * 
 * Converts a uri object to a string in the format <scheme>://<server_address>/<path>?<query_string>#<fragment>
 * 
 * @param \Psr\Http\Message\UriInterface $uri uri object to be converted to a string
 * 
 * @return string the string represntation of the uri object. 
 *                Eg. http://someserver.com/controller/action
 */
function s3MVC_UriToString(\Psr\Http\Message\UriInterface $uri)
{
    $scheme = $uri->getScheme();
    $authority = $uri->getAuthority();
    $basePath = s3MVC_GetBaseUrlPath();
    $path = $uri->getPath();
    $query = $uri->getQuery();
    $fragment = $uri->getFragment();
    $path = $basePath . '/' . ltrim($path, '/');
    return ($scheme ? $scheme . ':' : '') . ($authority ? '//' . $authority : '') . $path . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : '');
}
开发者ID:rotexsoft,项目名称:slim3-skeleton-mvc-tools,代码行数:20,代码来源:framework-helpers.php


注:本文中的Psr\Http\Message\UriInterface::getAuthority方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。