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

SitemapUrl   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getUrl() 0 4 1
A getLastModified() 0 4 1
A getPriority() 0 4 1
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