Passed
Push — master ( b97c32...e7e450 )
by Carlos C
10:36 queued 12s
created

UrlResponse::lastModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogosPopulate\Origins;
6
7
use DateTimeImmutable;
8
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
48
    {
49 11
        return $this->body;
50
    }
51
}
52