コード例 #1
0
 /**
  * @inheritdoc
  */
 public function benchmark($count, $uri)
 {
     $start = microtime(true);
     $memory = memory_get_usage();
     $uriParser = new UriParser();
     foreach ($this->generateUri($count, $uri) as $url) {
         $uriParser->parse($url);
     }
     return ['memory' => memory_get_usage() - $memory, 'duration' => microtime(true) - $start];
 }
コード例 #2
0
ファイル: Formatter.php プロジェクト: Zeichen32/uri
 /**
  * Format a URI authority according to the Formatter properties
  *
  * @param UriInterface|Uri $uri
  *
  * @return string
  */
 protected function formatAuthority($uri)
 {
     if ('' == $uri->getHost()) {
         return '';
     }
     $components = $this->uriParser->parse((string) $uri);
     $port = $components['port'];
     if (!empty($port)) {
         $port = ':' . $port;
     }
     return '//' . $this->uriParser->buildUserInfo($components['user'], $components['pass']) . $this->formatHost(new Host($components['host'])) . $port;
 }
コード例 #3
0
 private function validateSubjectResource($resource)
 {
     if (strpos($resource, 'acct:') === 0) {
         $resource = preg_replace('/@/', '%40', $resource, 1);
         $parseable = preg_replace('/^acct:/', 'acct://', $resource, 1);
     } else {
         $parseable = $resource;
     }
     $parser = new UriParser();
     $default = array('scheme' => null, 'user' => null, 'host' => null);
     $parts = array_merge($default, $parser->parse($parseable));
     if ($parts['scheme'] === null) {
         if ($parts['host'] !== null && $parts['user'] !== null) {
             $parts['scheme'] = 'acct';
         } else {
             $parts['scheme'] = 'https';
         }
     }
     if ($parts['scheme'] === null || $parts['host'] === null) {
         throw new BadRequestHttpException("Invalid resource");
     }
     return $resource;
 }