1 | <?php |
||
10 | class LocalTimeslot |
||
11 | { |
||
12 | /** |
||
13 | * @var LocalDate |
||
14 | * |
||
15 | * @PeekAndPoke\Component\Slumber\Annotation\Slumber\AsLocalDate() |
||
16 | */ |
||
17 | private $from; |
||
18 | |||
19 | /** |
||
20 | * @var LocalDate |
||
21 | * |
||
22 | * @PeekAndPoke\Component\Slumber\Annotation\Slumber\AsLocalDate() |
||
23 | */ |
||
24 | private $to; |
||
25 | |||
26 | /** |
||
27 | * @return LocalTimeslot |
||
28 | */ |
||
29 | 14 | public static function createEmpty() |
|
33 | |||
34 | /** |
||
35 | * @param LocalDate $from |
||
36 | * @param LocalDate $to |
||
37 | * |
||
38 | * @return LocalTimeslot |
||
39 | */ |
||
40 | 7 | public static function from(LocalDate $from, LocalDate $to) |
|
48 | |||
49 | /** |
||
50 | * LocalTimeslot cannot be constructed directly. |
||
51 | * |
||
52 | * @see from() |
||
53 | * @see createEmpty() |
||
54 | */ |
||
55 | 21 | protected function __construct() |
|
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | 4 | public function __toString() |
|
66 | |||
67 | /** |
||
68 | * @return bool |
||
69 | */ |
||
70 | 9 | public function isValid() |
|
76 | |||
77 | /** |
||
78 | * @param LocalTimeslot $other |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | 9 | public function equals(LocalTimeslot $other = null) |
|
102 | |||
103 | /** |
||
104 | * @return LocalDate |
||
105 | */ |
||
106 | 7 | public function getFrom() |
|
110 | |||
111 | /** |
||
112 | * @return LocalDate |
||
113 | */ |
||
114 | 7 | public function getTo() |
|
118 | |||
119 | /** |
||
120 | * @param LocalDate $from |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | 12 | public function setFrom(LocalDate $from = null) |
|
130 | |||
131 | /** |
||
132 | * @param LocalDate $to |
||
133 | * |
||
134 | * @return $this |
||
135 | */ |
||
136 | 12 | public function setTo(LocalDate $to = null) |
|
142 | |||
143 | /** |
||
144 | * Creates a new instance and moves the timeslot by the given number of days |
||
145 | * |
||
146 | * @param int $numDays |
||
147 | * |
||
148 | * @return LocalTimeslot |
||
149 | */ |
||
150 | 3 | public function modifyByDays($numDays) |
|
157 | |||
158 | /** |
||
159 | * Creates a new instance and moves the timeslot by the given number of days |
||
160 | * Takes into consideration the daylight savings possible issues |
||
161 | * |
||
162 | * @param int $numDays |
||
163 | * |
||
164 | * @return LocalTimeslot |
||
165 | */ |
||
166 | 3 | public function modifyByDaysDaylightSavingAware($numDays) |
|
173 | |||
174 | /** |
||
175 | * @return int |
||
176 | */ |
||
177 | 2 | public function getDurationInSecs() |
|
185 | |||
186 | /** |
||
187 | * @return float |
||
188 | */ |
||
189 | 2 | public function getDurationInMins() |
|
193 | } |
||
194 |