1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Recurrence\Model; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class Recurrence |
8
|
|
|
* @package Recurrence\Model |
9
|
|
|
*/ |
10
|
|
|
class Recurrence |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Frequency |
14
|
|
|
*/ |
15
|
|
|
private $frequency; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var \Datetime |
19
|
|
|
*/ |
20
|
|
|
private $periodStartAt; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var \Datetime |
24
|
|
|
*/ |
25
|
|
|
private $periodEndAt; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var integer |
29
|
|
|
*/ |
30
|
|
|
private $interval = 1; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var integer |
34
|
|
|
*/ |
35
|
|
|
private $count; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Recurrence constructor. |
39
|
|
|
*/ |
40
|
|
|
public function __construct() |
41
|
|
|
{ |
42
|
|
|
$this->setPeriodStartAt(new \DateTime()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param \Datetime $periodStartAt |
47
|
|
|
* @return $this |
48
|
|
|
*/ |
49
|
|
|
public function setPeriodStartAt(\Datetime $periodStartAt) |
50
|
|
|
{ |
51
|
|
|
$this->periodStartAt = $periodStartAt; |
52
|
|
|
|
53
|
|
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return \Datetime |
58
|
|
|
*/ |
59
|
|
|
public function getPeriodStartAt() |
60
|
|
|
{ |
61
|
|
|
return $this->periodStartAt; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param \Datetime $periodEndAt |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function setPeriodEndAt(\Datetime $periodEndAt) |
69
|
|
|
{ |
70
|
|
|
$this->periodEndAt = $periodEndAt; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return \Datetime |
77
|
|
|
*/ |
78
|
|
|
public function getPeriodEndAt() |
79
|
|
|
{ |
80
|
|
|
return $this->periodEndAt; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
|
|
public function hasPeriodEndAt() |
87
|
|
|
{ |
88
|
|
|
return $this->periodEndAt !== null; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param Frequency $frequency |
93
|
|
|
* @return $this |
94
|
|
|
*/ |
95
|
|
|
public function setFrequency(Frequency $frequency) |
96
|
|
|
{ |
97
|
|
|
$this->frequency = $frequency; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return Frequency |
104
|
|
|
*/ |
105
|
|
|
public function getFrequency() |
106
|
|
|
{ |
107
|
|
|
return $this->frequency; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return int |
112
|
|
|
*/ |
113
|
|
|
public function getInterval() |
114
|
|
|
{ |
115
|
|
|
return $this->interval; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param int $interval |
120
|
|
|
* @return $this |
121
|
|
|
*/ |
122
|
|
|
public function setInterval($interval) |
123
|
|
|
{ |
124
|
|
|
$this->interval = $interval; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return int |
131
|
|
|
*/ |
132
|
|
|
public function getCount() |
133
|
|
|
{ |
134
|
|
|
return $this->count; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return bool |
139
|
|
|
*/ |
140
|
|
|
public function hasCount() |
141
|
|
|
{ |
142
|
|
|
return $this->count !== null; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param int $count |
147
|
|
|
* @return $this |
148
|
|
|
*/ |
149
|
|
|
public function setCount($count) |
150
|
|
|
{ |
151
|
|
|
$this->count = $count; |
152
|
|
|
|
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|