index/src/Http/Headers/DateHeader.php

26 lines
573 B
PHP
Raw Normal View History

2022-09-13 13:13:11 +00:00
<?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()));
}
}