You are here

private static function ServerRequestFactory::marshalHostAndPortFromHeader in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php \Zend\Diactoros\ServerRequestFactory::marshalHostAndPortFromHeader()

Marshal the host and port from the request header

Parameters

stdClass $accumulator:

string|array $host:

Return value

void

1 call to ServerRequestFactory::marshalHostAndPortFromHeader()
ServerRequestFactory::marshalHostAndPortFromHeaders in vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php
Marshal the host and port from HTTP headers and/or the PHP environment

File

vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php, line 377

Class

ServerRequestFactory
Class for marshaling a request object from the current PHP environment.

Namespace

Zend\Diactoros

Code

private static function marshalHostAndPortFromHeader(stdClass $accumulator, $host) {
  if (is_array($host)) {
    $host = implode(', ', $host);
  }
  $accumulator->host = $host;
  $accumulator->port = null;

  // works for regname, IPv4 & IPv6
  if (preg_match('|\\:(\\d+)$|', $accumulator->host, $matches)) {
    $accumulator->host = substr($accumulator->host, 0, -1 * (strlen($matches[1]) + 1));
    $accumulator->port = (int) $matches[1];
  }
}