26 lines
573 B
PHP
26 lines
573 B
PHP
|
<?php
|
||
|
// DateHeader.php
|
||
|
// Created: 2022-02-14
|
||
|
// Updated: 2022-02-14
|
||
|
|
||
|
namespace Index\Http\Headers;
|
||
|
|
||
|
use Index\DateTime;
|
||
|
use Index\Http\HttpHeader;
|
||
|
|
||
|
class DateHeader {
|
||
|
private DateTime $dateTime;
|
||
|
|
||
|
public function __construct(DateTime $dateTime) {
|
||
|
$this->dateTime = $dateTime;
|
||
|
}
|
||
|
|
||
|
public function getDateTime(): DateTime {
|
||
|
return $this->dateTime;
|
||
|
}
|
||
|
|
||
|
public static function parse(HttpHeader $header): DateHeader {
|
||
|
return new DateHeader(DateTime::createFromFormat(\DateTimeInterface::RFC7231, $header->getFirstLine()));
|
||
|
}
|
||
|
}
|