index/src/Http/Headers/ProxyAuthorizationHeader.php

36 lines
872 B
PHP

<?php
// ProxyAuthorizationHeader.php
// Created: 2022-02-14
// Updated: 2022-02-27
namespace Index\Http\Headers;
use Index\Http\HttpHeader;
class ProxyAuthorizationHeader {
private string $method;
private string $params;
public function __construct(string $method, string $params) {
$this->method = $method;
$this->params = $params;
}
public function getMethod(): string {
return $this->method;
}
public function isMethod(string $method): bool {
return $this->method === strtolower($method);
}
public function getParams(): string {
return $this->params;
}
public static function parse(HttpHeader $header): ProxyAuthorizationHeader {
$parts = explode(' ', trim($header->getFirstLine()), 2);
return new ProxyAuthorizationHeader($parts[0], $parts[1] ?? '');
}
}