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

UrlResponse   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 41
ccs 12
cts 14
cp 0.8571
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A body() 0 3 1
A dateMatch() 0 3 1
A isSuccess() 0 3 1
A lastModified() 0 3 1
A httpStatus() 0 3 1
A __construct() 0 7 2
A url() 0 3 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