Phly\Http\ServerRequestFactory::marshalHostAndPortFromHeader PHP Method

marshalHostAndPortFromHeader() private static method

Marshal the host and port from the request header
private static marshalHostAndPortFromHeader ( stdClass $accumulator, string | array $host ) : void
$accumulator stdClass
$host string | array
return void
    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];
        }
    }