Total Complexity | 8 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class UrlResponse |
||
10 | { |
||
11 | private DateTimeImmutable $lastModified; |
||
12 | |||
13 | 18 | public function __construct( |
|
14 | private string $url, |
||
15 | private int $httpStatus, |
||
16 | DateTimeImmutable $lastModified = null, |
||
17 | private string $body = '' |
||
18 | ) { |
||
19 | 18 | $this->lastModified = ($lastModified) ?: new DateTimeImmutable(); |
|
20 | } |
||
21 | |||
22 | 16 | public function url(): string |
|
23 | { |
||
24 | 16 | return $this->url; |
|
25 | } |
||
26 | |||
27 | public function httpStatus(): int |
||
28 | { |
||
29 | return $this->httpStatus; |
||
30 | } |
||
31 | |||
32 | 2 | public function lastModified(): DateTimeImmutable |
|
33 | { |
||
34 | 2 | return $this->lastModified; |
|
35 | } |
||
36 | |||
37 | 8 | public function isSuccess(): bool |
|
38 | { |
||
39 | 8 | return 200 === $this->httpStatus; |
|
40 | } |
||
41 | |||
42 | 4 | public function dateMatch(DateTimeImmutable $date): bool |
|
43 | { |
||
44 | 4 | return ($this->lastModified->format('U') === $date->format('U')); |
|
45 | } |
||
46 | |||
47 | 11 | public function body(): string |
|
50 | } |
||
51 | } |
||
52 |