Completed
Push — master ( 1debd7...be65da )
by Jeroen
12:58 queued 12s
created

SitemapUrl::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 3
1
<?php
2
3
namespace Kunstmaan\SitemapBundle\Model;
4
5
class SitemapUrl
6
{
7
    /** @var string */
8
    private $url;
9
10
    /** @var \DateTimeImmutable */
11
    private $lastModified;
12
13
    /** @var float */
14
    private $priority;
15
16
    public function __construct(string $url, \DateTimeImmutable $lastModified, float $priority = 0.9)
17
    {
18
        if ($priority > 1 || $priority < 0) {
19
            throw new \InvalidArgumentException(sprintf('A sitemap url priority can\'t be higher than 1 or below 0. Value given "%s"', $priority));
20
        }
21
22
        $this->url = $url;
23
        $this->lastModified = $lastModified;
24
        $this->priority = $priority;
25
    }
26
27
    public function getUrl(): string
28
    {
29
        return $this->url;
30
    }
31
32
    public function getLastModified(): \DateTimeImmutable
33
    {
34
        return $this->lastModified;
35
    }
36
37
    public function getPriority(): float
38
    {
39
        return $this->priority;
40
    }
41
}
42