32 lines
751 B
PHP
32 lines
751 B
PHP
|
<?php
|
||
|
// ExpectHeader.php
|
||
|
// Created: 2022-02-14
|
||
|
// Updated: 2022-02-14
|
||
|
|
||
|
namespace Index\Http\Headers;
|
||
|
|
||
|
use Index\Http\HttpHeader;
|
||
|
|
||
|
class ExpectHeader {
|
||
|
private int $statusCode;
|
||
|
private string $statusText;
|
||
|
|
||
|
public function __construct(int $statusCode, string $statusText) {
|
||
|
$this->statusCode = $statusCode;
|
||
|
$this->statusText = $statusText;
|
||
|
}
|
||
|
|
||
|
public function getStatusCode(): int {
|
||
|
return $this->statusCode;
|
||
|
}
|
||
|
|
||
|
public function getStatusText(): string {
|
||
|
return $this->statusText;
|
||
|
}
|
||
|
|
||
|
public static function parse(HttpHeader $header): ExpectHeader {
|
||
|
$value = explode('-', $header->getFirstLine(), 2);
|
||
|
return new ExpectHeader(intval($value[0]), $value[1] ?? '');
|
||
|
}
|
||
|
}
|