2022-09-13 13:13:11 +00:00
|
|
|
<?php
|
|
|
|
// ExpectHeader.php
|
|
|
|
// Created: 2022-02-14
|
2023-01-01 19:00:00 +00:00
|
|
|
// Updated: 2023-01-01
|
2022-09-13 13:13:11 +00:00
|
|
|
|
|
|
|
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);
|
2023-01-01 19:00:00 +00:00
|
|
|
return new ExpectHeader((int)$value[0], $value[1] ?? '');
|
2022-09-13 13:13:11 +00:00
|
|
|
}
|
|
|
|
}
|