本文整理汇总了PHP中GuzzleHttp\Psr7\Uri::getPort方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::getPort方法的具体用法?PHP Uri::getPort怎么用?PHP Uri::getPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Psr7\Uri
的用法示例。
在下文中一共展示了Uri::getPort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Options $options, OutputInterface $ouput)
{
$timeout = $options->getTimeout();
$client = new ClientGuzzle(['timeout' => $timeout]);
$url = $options->getUrl();
$response = $client->get($url);
if ($response->getStatusCode() != 200) {
throw new RuntimeException(sprintf('Cannot access this url: "%s"', $url));
}
$uri = new Uri($url);
$baseUri = $uri->getScheme() . '://' . $uri->getHost();
if (!empty($uri->getPort())) {
$baseUri .= ':' . $uri->getPort();
}
$options->setBaseUri($baseUri);
$this->options = $options;
$this->output = $ouput;
}
示例2: testAllowsFalseyUrlParts
public function testAllowsFalseyUrlParts()
{
$url = new Uri('http://a:1/0?0#0');
$this->assertSame('a', $url->getHost());
$this->assertEquals(1, $url->getPort());
$this->assertSame('/0', $url->getPath());
$this->assertEquals('0', (string) $url->getQuery());
$this->assertSame('0', $url->getFragment());
$this->assertEquals('http://a:1/0?0#0', (string) $url);
$url = new Uri('');
$this->assertSame('', (string) $url);
$url = new Uri('0');
$this->assertSame('/0', (string) $url);
}
示例3: assertUriEquals
protected function assertUriEquals($expectedUri, $actualUri)
{
if (is_string($expectedUri)) {
$expectedUri = new Psr7\Uri($expectedUri);
}
if (is_string($actualUri)) {
$actualUri = new Psr7\Uri($actualUri);
}
$this->assertEquals($expectedUri->getScheme(), $actualUri->getScheme());
$this->assertEquals($expectedUri->getPort(), $actualUri->getPort());
$this->assertEquals($expectedUri->getHost(), $actualUri->getHost());
$this->assertEquals($expectedUri->getPath(), $actualUri->getPath());
$expectedQueryParts = Psr7\parse_query($expectedUri->getQuery());
$actualQueryParts = Psr7\parse_query($actualUri->getQuery());
$this->assertEquals($expectedQueryParts, $actualQueryParts);
}
示例4: extractHeaders
private function extractHeaders(BrowserKitRequest $request)
{
$headers = [];
$server = $request->getServer();
$uri = new Uri($request->getUri());
$server['HTTP_HOST'] = $uri->getHost();
$port = $uri->getPort();
if ($port !== null && $port !== 443 && $port != 80) {
$server['HTTP_HOST'] .= ':' . $port;
}
$contentHeaders = array('Content-Length' => true, 'Content-Md5' => true, 'Content-Type' => true);
foreach ($server as $header => $val) {
$header = implode('-', array_map('ucfirst', explode('-', strtolower(str_replace('_', '-', $header)))));
if (strpos($header, 'Http-') === 0) {
$headers[substr($header, 5)] = $val;
} elseif (isset($contentHeaders[$header])) {
$headers[$header] = $val;
}
}
return $headers;
}
示例5: testDefaultReturnValuesOfGetters
public function testDefaultReturnValuesOfGetters()
{
$uri = new Uri();
$this->assertSame('', $uri->getScheme());
$this->assertSame('', $uri->getAuthority());
$this->assertSame('', $uri->getUserInfo());
$this->assertSame('', $uri->getHost());
$this->assertNull($uri->getPort());
$this->assertSame('', $uri->getPath());
$this->assertSame('', $uri->getQuery());
$this->assertSame('', $uri->getFragment());
}