1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace DL\SitemapBundle\Definition; |
5
|
|
|
|
6
|
|
|
use DL\SitemapBundle\Enum\ChangeFrequencyEnum; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Defines a resource within a sitemap collection. |
10
|
|
|
* |
11
|
|
|
* @see Sitemap |
12
|
|
|
* @package DL\SitemapBundle\Definition |
13
|
|
|
* @author Petre Pătrașc <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class SitemapResource |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The title of the resource. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $title; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The absolute URL of where the resource can be accessed. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $location; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The date at which the resource was last modified. |
33
|
|
|
* |
34
|
|
|
* @var \DateTime |
35
|
|
|
*/ |
36
|
|
|
protected $lastModified; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The change frequency at which this resource is updated. |
40
|
|
|
* |
41
|
|
|
* @see ChangeFrequencyEnum |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $changeFrequency; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The priority that this resource should be given within a sitemap. |
48
|
|
|
* |
49
|
|
|
* @var float |
50
|
|
|
*/ |
51
|
|
|
protected $priority; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* SitemapResource constructor. |
55
|
|
|
* |
56
|
|
|
* @param string $title |
57
|
|
|
* @param string $location |
58
|
|
|
* @param \DateTime $lastModified |
59
|
|
|
* @param string $changeFrequency |
60
|
|
|
* @param float $priority |
61
|
|
|
*/ |
62
|
15 |
|
public function __construct( |
63
|
|
|
string $title, |
64
|
|
|
string $location, |
65
|
|
|
\DateTime $lastModified, |
66
|
|
|
string $changeFrequency, |
67
|
|
|
float $priority |
68
|
|
|
) { |
69
|
15 |
|
$this->title = $title; |
70
|
15 |
|
$this->location = $location; |
71
|
15 |
|
$this->lastModified = $lastModified; |
72
|
15 |
|
$this->changeFrequency = $changeFrequency; |
73
|
15 |
|
$this->priority = $priority; |
74
|
15 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
12 |
|
public function getTitle(): string |
80
|
|
|
{ |
81
|
12 |
|
return $this->title; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
11 |
|
public function getLocation(): string |
88
|
|
|
{ |
89
|
11 |
|
return $this->location; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return \DateTime |
94
|
|
|
*/ |
95
|
2 |
|
public function getLastModified(): \DateTime |
96
|
|
|
{ |
97
|
2 |
|
return $this->lastModified; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
10 |
|
public function getChangeFrequency(): string |
104
|
|
|
{ |
105
|
10 |
|
return $this->changeFrequency; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return float |
110
|
|
|
*/ |
111
|
9 |
|
public function getPriority(): float |
112
|
|
|
{ |
113
|
9 |
|
return $this->priority; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|