|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the eluceo/iCal package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Markus Poerschke <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Eluceo\iCal\Property\Event; |
|
13
|
|
|
|
|
14
|
|
|
use Eluceo\iCal\ParameterBag; |
|
15
|
|
|
use Eluceo\iCal\Property; |
|
16
|
|
|
use Eluceo\iCal\Util\DateUtil; |
|
17
|
|
|
use Eluceo\iCal\Property\ValueInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Implementation of Recurrence Id. |
|
21
|
|
|
* |
|
22
|
|
|
* @see http://www.ietf.org/rfc/rfc2445.txt 4.8.4.4 Recurrence ID |
|
23
|
|
|
*/ |
|
24
|
|
|
class RecurrenceId extends Property |
|
25
|
|
|
{ |
|
26
|
|
|
const PROPERTY_NAME = 'RECURRENCE-ID'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The effective range of recurrence instances from the instance |
|
30
|
|
|
* specified by the recurrence identifier specified by the property. |
|
31
|
|
|
*/ |
|
32
|
|
|
const RANGE_THISANDPRIOR = 'THISANDPRIOR'; |
|
33
|
|
|
const RANGE_THISANDFUTURE = 'THISANDFUTURE'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* The dateTime to identify a particular instance of a recurring event which is getting modified. |
|
37
|
|
|
* |
|
38
|
|
|
* @var \DateTime |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $dateTime; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Specify the effective range of recurrence instances from the instance. |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $range; |
|
48
|
|
|
|
|
49
|
|
|
public function __construct(\DateTime $dateTime = null) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->parameterBag = new ParameterBag(); |
|
52
|
|
|
if (isset($dateTime)) { |
|
53
|
|
|
$this->dateTime = $dateTime; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function applyTimeSettings($noTime = false, $useTimezone = false, $useUtc = false) |
|
58
|
|
|
{ |
|
59
|
|
|
$params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $useUtc); |
|
|
|
|
|
|
60
|
|
|
foreach ($params as $name => $value) { |
|
61
|
|
|
$this->parameterBag->setParam($name, $value); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if ($this->range) { |
|
65
|
|
|
$this->parameterBag->setParam('RANGE', $this->range); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$this->setValue(DateUtil::getDateString($this->dateTime, $noTime, $useTimezone, $useUtc)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return DateTime |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getDatetime() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->dateTime; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param \DateTime $dateTime |
|
81
|
|
|
* |
|
82
|
|
|
* @return \Eluceo\iCal\Property\Event\RecurrenceId |
|
83
|
|
|
*/ |
|
84
|
|
|
public function setDatetime(\DateTime $dateTime) |
|
85
|
|
|
{ |
|
86
|
|
|
$this->dateTime = $dateTime; |
|
87
|
|
|
|
|
88
|
|
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getRange() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->range; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param string $range |
|
101
|
|
|
* |
|
102
|
|
|
* @return \Eluceo\iCal\Property\Event\RecurrenceId |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setRange($range) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->range = $range; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Get all unfolded lines. |
|
111
|
|
|
* |
|
112
|
|
|
* @return array |
|
113
|
|
|
*/ |
|
114
|
|
|
public function toLines() |
|
115
|
|
|
{ |
|
116
|
|
|
if (!$this->value instanceof ValueInterface) { |
|
117
|
|
|
throw new \Exception('The value must implement the ValueInterface. Call RecurrenceId::applyTimeSettings() before adding RecurrenceId.'); |
|
118
|
|
|
} else { |
|
119
|
|
|
return parent::toLines(); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* {@inheritdoc} |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getName() |
|
127
|
|
|
{ |
|
128
|
|
|
return self::PROPERTY_NAME; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.