|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* GpsLab component. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Peter Gribanov <[email protected]> |
|
6
|
|
|
* @copyright Copyright (c) 2011, Peter Gribanov |
|
7
|
|
|
* @license http://opensource.org/licenses/MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace GpsLab\Component\Sitemap\Url; |
|
11
|
|
|
|
|
12
|
|
|
class Url |
|
13
|
|
|
{ |
|
14
|
|
|
const CHANGE_FREQ_ALWAYS = 'always'; |
|
15
|
|
|
const CHANGE_FREQ_HOURLY = 'hourly'; |
|
16
|
|
|
const CHANGE_FREQ_DAILY = 'daily'; |
|
17
|
|
|
const CHANGE_FREQ_WEEKLY = 'weekly'; |
|
18
|
|
|
const CHANGE_FREQ_MONTHLY = 'monthly'; |
|
19
|
|
|
const CHANGE_FREQ_YEARLY = 'yearly'; |
|
20
|
|
|
const CHANGE_FREQ_NEVER = 'never'; |
|
21
|
|
|
|
|
22
|
|
|
const DEFAULT_PRIORITY = '1.0'; |
|
23
|
|
|
|
|
24
|
|
|
const DEFAULT_CHANGE_FREQ = self::CHANGE_FREQ_WEEKLY; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
private $loc = ''; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var \DateTime |
|
33
|
|
|
*/ |
|
34
|
|
|
private $last_mod; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $change_freq = ''; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $priority = ''; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param string $loc |
|
48
|
|
|
* @param \DateTimeImmutable|null $last_mod |
|
49
|
|
|
* @param string|null $change_freq |
|
50
|
|
|
* @param string|null $priority |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct($loc, \DateTimeImmutable $last_mod = null, $change_freq = null, $priority = null) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->loc = $loc; |
|
55
|
|
|
$this->last_mod = $last_mod ?: new \DateTimeImmutable(); |
|
|
|
|
|
|
56
|
|
|
$this->change_freq = $change_freq ?: self::DEFAULT_CHANGE_FREQ; |
|
57
|
|
|
$this->priority = $priority ?: self::DEFAULT_PRIORITY; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getLoc() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->loc; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return \DateTime |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getLastMod() |
|
72
|
|
|
{ |
|
73
|
|
|
return clone $this->last_mod; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return string |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getChangeFreq() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->change_freq; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getPriority() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->priority; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..