Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Event often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Event, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
29 | class Event extends Component |
||
30 | { |
||
31 | const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE'; |
||
32 | const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT'; |
||
33 | |||
34 | const STATUS_TENTATIVE = 'TENTATIVE'; |
||
35 | const STATUS_CONFIRMED = 'CONFIRMED'; |
||
36 | const STATUS_CANCELLED = 'CANCELLED'; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $uniqueId; |
||
42 | |||
43 | /** |
||
44 | * The property indicates the date/time that the instance of |
||
45 | * the iCalendar object was created. |
||
46 | * |
||
47 | * The value MUST be specified in the UTC time format. |
||
48 | * |
||
49 | * @var \DateTime |
||
50 | */ |
||
51 | protected $dtStamp; |
||
52 | |||
53 | /** |
||
54 | * @var \DateTime |
||
55 | */ |
||
56 | protected $dtStart; |
||
57 | |||
58 | /** |
||
59 | * Preferentially chosen over the duration if both are set. |
||
60 | * |
||
61 | * @var \DateTime |
||
62 | */ |
||
63 | protected $dtEnd; |
||
64 | |||
65 | /** |
||
66 | * @var \DateInterval |
||
67 | */ |
||
68 | protected $duration; |
||
69 | |||
70 | /** |
||
71 | * @var bool |
||
72 | */ |
||
73 | protected $noTime = false; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | protected $url; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $location; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | */ |
||
88 | protected $locationTitle; |
||
89 | |||
90 | /** |
||
91 | * @var Geo |
||
92 | */ |
||
93 | protected $locationGeo; |
||
94 | |||
95 | /** |
||
96 | * @var string |
||
97 | */ |
||
98 | protected $summary; |
||
99 | |||
100 | /** |
||
101 | * @var Organizer |
||
102 | */ |
||
103 | protected $organizer; |
||
104 | |||
105 | /** |
||
106 | * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7 |
||
107 | * |
||
108 | * @var string |
||
109 | */ |
||
110 | protected $transparency = self::TIME_TRANSPARENCY_OPAQUE; |
||
111 | |||
112 | /** |
||
113 | * If set to true the timezone will be added to the event. |
||
114 | * |
||
115 | * @var bool |
||
116 | */ |
||
117 | protected $useTimezone = false; |
||
118 | |||
119 | /** |
||
120 | * If set will we used as the timezone identifier. |
||
121 | * |
||
122 | * @var string |
||
123 | */ |
||
124 | protected $timezoneString = ''; |
||
125 | |||
126 | /** |
||
127 | * @var int |
||
128 | */ |
||
129 | protected $sequence = 0; |
||
130 | |||
131 | /** |
||
132 | * @var Attendees |
||
133 | */ |
||
134 | protected $attendees; |
||
135 | |||
136 | /** |
||
137 | * @var string |
||
138 | */ |
||
139 | protected $description; |
||
140 | |||
141 | /** |
||
142 | * @var string |
||
143 | */ |
||
144 | protected $descriptionHTML; |
||
145 | |||
146 | /** |
||
147 | * @var string |
||
148 | */ |
||
149 | protected $status; |
||
150 | |||
151 | /** |
||
152 | * @var RecurrenceRule |
||
153 | */ |
||
154 | protected $recurrenceRule; |
||
155 | |||
156 | /** |
||
157 | * @var array |
||
158 | */ |
||
159 | protected $recurrenceRules = []; |
||
160 | |||
161 | /** |
||
162 | * This property specifies the date and time that the calendar |
||
163 | * information was created. |
||
164 | * |
||
165 | * The value MUST be specified in the UTC time format. |
||
166 | * |
||
167 | * @var \DateTime |
||
168 | */ |
||
169 | protected $created; |
||
170 | |||
171 | /** |
||
172 | * The property specifies the date and time that the information |
||
173 | * associated with the calendar component was last revised. |
||
174 | * |
||
175 | * The value MUST be specified in the UTC time format. |
||
176 | * |
||
177 | * @var \DateTime |
||
178 | */ |
||
179 | protected $modified; |
||
180 | |||
181 | /** |
||
182 | * Indicates if the UTC time should be used or not. |
||
183 | * |
||
184 | * @var bool |
||
185 | */ |
||
186 | protected $useUtc = true; |
||
187 | |||
188 | /** |
||
189 | * @var bool |
||
190 | */ |
||
191 | protected $cancelled; |
||
192 | |||
193 | /** |
||
194 | * This property is used to specify categories or subtypes |
||
195 | * of the calendar component. The categories are useful in searching |
||
196 | * for a calendar component of a particular type and category. |
||
197 | * |
||
198 | * @see https://tools.ietf.org/html/rfc5545#section-3.8.1.2 |
||
199 | * |
||
200 | * @var array |
||
201 | */ |
||
202 | protected $categories; |
||
203 | |||
204 | /** |
||
205 | * https://tools.ietf.org/html/rfc5545#section-3.8.1.3. |
||
206 | * |
||
207 | * @var bool |
||
208 | */ |
||
209 | protected $isPrivate = false; |
||
210 | |||
211 | /** |
||
212 | * Dates to be excluded from a series of events. |
||
213 | * |
||
214 | * @var \DateTimeInterface[] |
||
215 | */ |
||
216 | protected $exDates = []; |
||
217 | |||
218 | /** |
||
219 | * @var RecurrenceId |
||
220 | */ |
||
221 | protected $recurrenceId; |
||
222 | |||
223 | 25 | public function __construct(string $uniqueId = null) |
|
224 | { |
||
225 | 25 | if (null == $uniqueId) { |
|
|
|||
226 | 3 | $uniqueId = uniqid(); |
|
227 | } |
||
228 | |||
229 | 25 | $this->uniqueId = $uniqueId; |
|
230 | 25 | $this->attendees = new Attendees(); |
|
231 | 25 | } |
|
232 | |||
233 | /** |
||
234 | * {@inheritdoc} |
||
235 | */ |
||
236 | 6 | public function getType() |
|
237 | { |
||
238 | 6 | return 'VEVENT'; |
|
239 | } |
||
240 | |||
241 | /** |
||
242 | * {@inheritdoc} |
||
243 | */ |
||
244 | 16 | public function buildPropertyBag() |
|
245 | { |
||
246 | 16 | $propertyBag = new PropertyBag(); |
|
247 | |||
248 | // mandatory information |
||
249 | 16 | $propertyBag->set('UID', $this->uniqueId); |
|
250 | |||
251 | 16 | $propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
|
252 | 16 | $propertyBag->set('SEQUENCE', $this->sequence); |
|
253 | 16 | $propertyBag->set('TRANSP', $this->transparency); |
|
254 | |||
255 | 16 | if ($this->status) { |
|
256 | $propertyBag->set('STATUS', $this->status); |
||
257 | } |
||
258 | |||
259 | // An event can have a 'dtend' or 'duration', but not both. |
||
260 | 16 | if ($this->dtEnd !== null) { |
|
261 | 3 | $dtEnd = clone $this->dtEnd; |
|
262 | 3 | if ($this->noTime === true) { |
|
263 | $dtEnd = $dtEnd->add(new \DateInterval('P1D')); |
||
264 | } |
||
265 | 3 | $propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
|
266 | 13 | } elseif ($this->duration !== null) { |
|
267 | 1 | $propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS')); |
|
268 | } |
||
269 | |||
270 | // optional information |
||
271 | 16 | if (null != $this->url) { |
|
272 | 1 | $propertyBag->set('URL', $this->url); |
|
273 | } |
||
274 | |||
275 | 16 | if (null != $this->location) { |
|
276 | 2 | $propertyBag->set('LOCATION', $this->location); |
|
277 | |||
278 | 2 | if (null != $this->locationGeo) { |
|
279 | 1 | $propertyBag->add( |
|
280 | 1 | new Property( |
|
281 | 1 | 'X-APPLE-STRUCTURED-LOCATION', |
|
282 | 1 | new RawStringValue('geo:' . $this->locationGeo->getGeoLocationAsString(',')), |
|
283 | [ |
||
284 | 1 | 'VALUE' => 'URI', |
|
285 | 1 | 'X-ADDRESS' => $this->location, |
|
286 | 1 | 'X-APPLE-RADIUS' => 49, |
|
287 | 1 | 'X-TITLE' => $this->locationTitle, |
|
288 | ] |
||
289 | ) |
||
290 | ); |
||
291 | } |
||
292 | } |
||
293 | |||
294 | 16 | if (null != $this->locationGeo) { |
|
295 | 2 | $propertyBag->add($this->locationGeo); |
|
296 | } |
||
297 | |||
298 | 16 | if (null != $this->summary) { |
|
299 | 1 | $propertyBag->set('SUMMARY', $this->summary); |
|
300 | } |
||
301 | |||
302 | 16 | if (null != $this->attendees) { |
|
303 | 16 | $propertyBag->add($this->attendees); |
|
304 | } |
||
305 | |||
306 | 16 | $propertyBag->set('CLASS', $this->isPrivate ? 'PRIVATE' : 'PUBLIC'); |
|
307 | |||
308 | 16 | if (null != $this->description) { |
|
309 | 3 | $propertyBag->set('DESCRIPTION', $this->description); |
|
310 | } |
||
311 | |||
312 | 16 | if (null != $this->descriptionHTML) { |
|
313 | $propertyBag->add( |
||
314 | new Property( |
||
315 | 'X-ALT-DESC', |
||
316 | $this->descriptionHTML, |
||
317 | [ |
||
318 | 'FMTTYPE' => 'text/html', |
||
319 | ] |
||
320 | ) |
||
321 | ); |
||
322 | } |
||
323 | |||
324 | 16 | if (null != $this->recurrenceRule) { |
|
325 | $propertyBag->set('RRULE', $this->recurrenceRule); |
||
326 | } |
||
327 | |||
328 | 16 | foreach ($this->recurrenceRules as $recurrenceRule) { |
|
329 | $propertyBag->set('RRULE', $recurrenceRule); |
||
330 | } |
||
331 | |||
332 | 16 | if (null != $this->recurrenceId) { |
|
333 | $this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString); |
||
334 | $propertyBag->add($this->recurrenceId); |
||
335 | } |
||
336 | |||
337 | 16 | if (!empty($this->exDates)) { |
|
338 | $propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
||
339 | } |
||
340 | |||
341 | 16 | if ($this->cancelled) { |
|
342 | $propertyBag->set('STATUS', 'CANCELLED'); |
||
343 | } |
||
344 | |||
345 | 16 | if (null != $this->organizer) { |
|
346 | 2 | $propertyBag->add($this->organizer); |
|
347 | } |
||
348 | |||
349 | 16 | if ($this->noTime) { |
|
350 | 1 | $propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); |
|
351 | } |
||
352 | |||
353 | 16 | if (null != $this->categories) { |
|
354 | $propertyBag->set('CATEGORIES', $this->categories); |
||
355 | } |
||
356 | |||
357 | 16 | $propertyBag->add( |
|
358 | 16 | new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTimeImmutable(), false, false, true) |
|
359 | ); |
||
360 | |||
361 | 16 | if ($this->created) { |
|
362 | $propertyBag->add(new DateTimeProperty('CREATED', $this->created, false, false, true)); |
||
363 | } |
||
364 | |||
365 | 16 | if ($this->modified) { |
|
366 | $propertyBag->add(new DateTimeProperty('LAST-MODIFIED', $this->modified, false, false, true)); |
||
367 | } |
||
368 | |||
369 | 16 | return $propertyBag; |
|
370 | } |
||
371 | |||
372 | /** |
||
373 | * @param $dtEnd |
||
374 | * |
||
375 | * @return $this |
||
376 | */ |
||
377 | 4 | public function setDtEnd($dtEnd) |
|
378 | { |
||
379 | 4 | $this->dtEnd = $dtEnd; |
|
380 | |||
381 | 4 | return $this; |
|
382 | } |
||
383 | |||
384 | 2 | public function getDtEnd() |
|
385 | { |
||
386 | 2 | return $this->dtEnd; |
|
387 | } |
||
388 | |||
389 | 4 | public function setDtStart($dtStart) |
|
390 | { |
||
391 | 4 | $this->dtStart = $dtStart; |
|
392 | |||
393 | 4 | return $this; |
|
394 | } |
||
395 | |||
396 | 2 | public function getDtStart() |
|
397 | { |
||
398 | 2 | return $this->dtStart; |
|
399 | } |
||
400 | |||
401 | /** |
||
402 | * @param $dtStamp |
||
403 | * |
||
404 | * @return $this |
||
405 | */ |
||
406 | 1 | public function setDtStamp($dtStamp) |
|
407 | { |
||
408 | 1 | $this->dtStamp = $dtStamp; |
|
409 | |||
410 | 1 | return $this; |
|
411 | } |
||
412 | |||
413 | /** |
||
414 | * @param $duration |
||
415 | * |
||
416 | * @return $this |
||
417 | */ |
||
418 | 1 | public function setDuration($duration) |
|
419 | { |
||
420 | 1 | $this->duration = $duration; |
|
421 | |||
422 | 1 | return $this; |
|
423 | } |
||
424 | |||
425 | /** |
||
426 | * @param string $location |
||
427 | * @param string $title |
||
428 | * @param Geo|string $geo |
||
429 | * |
||
430 | * @return $this |
||
431 | */ |
||
432 | 3 | public function setLocation($location, $title = '', $geo = null) |
|
433 | { |
||
434 | 3 | if (is_scalar($geo)) { |
|
435 | 1 | $geo = Geo::fromString($geo); |
|
436 | 2 | } elseif (!is_null($geo) && !$geo instanceof Geo) { |
|
437 | 1 | $className = get_class($geo); |
|
438 | 1 | throw new \InvalidArgumentException( |
|
439 | "The parameter 'geo' must be a string or an instance of " . Geo::class |
||
440 | 1 | . " but an instance of {$className} was given." |
|
441 | ); |
||
442 | } |
||
443 | |||
444 | 2 | $this->location = $location; |
|
445 | 2 | $this->locationTitle = $title; |
|
446 | 2 | $this->locationGeo = $geo; |
|
447 | |||
448 | 2 | return $this; |
|
449 | } |
||
450 | |||
451 | /** |
||
452 | * @param Geo $geoProperty |
||
453 | * |
||
454 | * @return $this |
||
455 | */ |
||
456 | 1 | public function setGeoLocation(Geo $geoProperty) |
|
457 | { |
||
458 | 1 | $this->locationGeo = $geoProperty; |
|
459 | |||
460 | 1 | return $this; |
|
461 | } |
||
462 | |||
463 | /** |
||
464 | * @param $noTime |
||
465 | * |
||
466 | * @return $this |
||
467 | */ |
||
468 | 1 | public function setNoTime($noTime) |
|
469 | { |
||
470 | 1 | $this->noTime = $noTime; |
|
471 | |||
472 | 1 | return $this; |
|
473 | } |
||
474 | |||
475 | /** |
||
476 | * @param int $sequence |
||
477 | * |
||
478 | * @return $this |
||
479 | */ |
||
480 | 2 | public function setSequence($sequence) |
|
481 | { |
||
482 | 2 | $this->sequence = $sequence; |
|
483 | |||
484 | 2 | return $this; |
|
485 | } |
||
486 | |||
487 | /** |
||
488 | * @return int |
||
489 | */ |
||
490 | 1 | public function getSequence() |
|
491 | { |
||
492 | 1 | return $this->sequence; |
|
493 | } |
||
494 | |||
495 | /** |
||
496 | * @param Organizer $organizer |
||
497 | * |
||
498 | * @return $this |
||
499 | */ |
||
500 | 2 | public function setOrganizer(Organizer $organizer) |
|
501 | { |
||
502 | 2 | $this->organizer = $organizer; |
|
503 | |||
504 | 2 | return $this; |
|
505 | } |
||
506 | |||
507 | /** |
||
508 | * @param $summary |
||
509 | * |
||
510 | * @return $this |
||
511 | */ |
||
512 | 1 | public function setSummary($summary) |
|
513 | { |
||
514 | 1 | $this->summary = $summary; |
|
515 | |||
516 | 1 | return $this; |
|
517 | } |
||
518 | |||
519 | /** |
||
520 | * @param $uniqueId |
||
521 | * |
||
522 | * @return $this |
||
523 | */ |
||
524 | 1 | public function setUniqueId($uniqueId) |
|
525 | { |
||
526 | 1 | $this->uniqueId = $uniqueId; |
|
527 | |||
528 | 1 | return $this; |
|
529 | } |
||
530 | |||
531 | /** |
||
532 | * @return string |
||
533 | */ |
||
534 | 2 | public function getUniqueId() |
|
535 | { |
||
536 | 2 | return $this->uniqueId; |
|
537 | } |
||
538 | |||
539 | /** |
||
540 | * @param $url |
||
541 | * |
||
542 | * @return $this |
||
543 | */ |
||
544 | 1 | public function setUrl($url) |
|
545 | { |
||
546 | 1 | $this->url = $url; |
|
547 | |||
548 | 1 | return $this; |
|
549 | } |
||
550 | |||
551 | /** |
||
552 | * @param $useTimezone |
||
553 | * |
||
554 | * @return $this |
||
555 | */ |
||
556 | public function setUseTimezone($useTimezone) |
||
557 | { |
||
558 | $this->useTimezone = $useTimezone; |
||
559 | |||
560 | return $this; |
||
561 | } |
||
562 | |||
563 | /** |
||
564 | * @return bool |
||
565 | */ |
||
566 | public function getUseTimezone() |
||
570 | |||
571 | /** |
||
572 | * @param $timezoneString |
||
573 | * |
||
574 | * @return $this |
||
575 | */ |
||
576 | 2 | public function setTimezoneString($timezoneString) |
|
582 | |||
583 | /** |
||
584 | * @return bool |
||
585 | */ |
||
586 | 1 | public function getTimezoneString() |
|
587 | { |
||
588 | 1 | return $this->timezoneString; |
|
589 | } |
||
590 | |||
591 | /** |
||
592 | * @param Attendees $attendees |
||
593 | * |
||
594 | * @return $this |
||
595 | */ |
||
596 | public function setAttendees(Attendees $attendees) |
||
597 | { |
||
598 | $this->attendees = $attendees; |
||
599 | |||
600 | return $this; |
||
601 | } |
||
602 | |||
603 | /** |
||
604 | * @param string $attendee |
||
605 | * @param array $params |
||
606 | * |
||
607 | * @return $this |
||
608 | */ |
||
609 | public function addAttendee($attendee, $params = []) |
||
610 | { |
||
611 | $this->attendees->add($attendee, $params); |
||
612 | |||
613 | return $this; |
||
614 | } |
||
615 | |||
616 | /** |
||
617 | * @return Attendees |
||
618 | */ |
||
619 | public function getAttendees(): Attendees |
||
623 | |||
624 | /** |
||
625 | * @param $description |
||
626 | * |
||
627 | * @return $this |
||
628 | */ |
||
629 | 3 | public function setDescription($description) |
|
630 | { |
||
631 | 3 | $this->description = $description; |
|
632 | |||
633 | 3 | return $this; |
|
634 | } |
||
635 | |||
636 | /** |
||
637 | * @param $descriptionHTML |
||
638 | * |
||
639 | * @return $this |
||
640 | */ |
||
641 | public function setDescriptionHTML($descriptionHTML) |
||
642 | { |
||
643 | $this->descriptionHTML = $descriptionHTML; |
||
644 | |||
645 | return $this; |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * @param bool $useUtc |
||
650 | * |
||
651 | * @return $this |
||
652 | */ |
||
653 | public function setUseUtc($useUtc = true) |
||
654 | { |
||
655 | $this->useUtc = $useUtc; |
||
656 | |||
657 | return $this; |
||
658 | } |
||
659 | |||
660 | /** |
||
661 | * @return string |
||
662 | */ |
||
663 | public function getDescription() |
||
667 | |||
668 | /** |
||
669 | * @return string |
||
670 | */ |
||
671 | public function getDescriptionHTML() |
||
672 | { |
||
673 | return $this->descriptionHTML; |
||
674 | } |
||
675 | |||
676 | /** |
||
677 | * @param $status |
||
678 | * |
||
679 | * @return $this |
||
680 | */ |
||
681 | public function setCancelled($status) |
||
682 | { |
||
683 | $this->cancelled = (bool) $status; |
||
684 | |||
685 | return $this; |
||
686 | } |
||
687 | |||
688 | /** |
||
689 | * @param $transparency |
||
690 | * |
||
691 | * @return $this |
||
692 | * |
||
693 | * @throws \InvalidArgumentException |
||
694 | */ |
||
695 | View Code Duplication | public function setTimeTransparency($transparency) |
|
696 | { |
||
697 | $transparency = strtoupper($transparency); |
||
698 | if ($transparency === self::TIME_TRANSPARENCY_OPAQUE |
||
699 | || $transparency === self::TIME_TRANSPARENCY_TRANSPARENT |
||
700 | ) { |
||
701 | $this->transparency = $transparency; |
||
702 | } else { |
||
703 | throw new \InvalidArgumentException('Invalid value for transparancy'); |
||
704 | } |
||
705 | |||
706 | return $this; |
||
707 | } |
||
708 | |||
709 | /** |
||
710 | * @param $status |
||
711 | * |
||
712 | * @return $this |
||
713 | * |
||
714 | * @throws \InvalidArgumentException |
||
715 | */ |
||
716 | public function setStatus($status) |
||
717 | { |
||
718 | $status = strtoupper($status); |
||
719 | if ($status == self::STATUS_CANCELLED |
||
720 | || $status == self::STATUS_CONFIRMED |
||
721 | || $status == self::STATUS_TENTATIVE |
||
722 | ) { |
||
723 | $this->status = $status; |
||
724 | } else { |
||
725 | throw new \InvalidArgumentException('Invalid value for status'); |
||
726 | } |
||
727 | |||
728 | return $this; |
||
729 | } |
||
730 | |||
731 | /** |
||
732 | * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead. |
||
733 | * |
||
734 | * @param RecurrenceRule $recurrenceRule |
||
735 | * |
||
736 | * @return $this |
||
737 | */ |
||
738 | public function setRecurrenceRule(RecurrenceRule $recurrenceRule) |
||
739 | { |
||
740 | @trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED); |
||
741 | |||
742 | $this->recurrenceRule = $recurrenceRule; |
||
743 | |||
744 | return $this; |
||
745 | } |
||
746 | |||
747 | /** |
||
748 | * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead. |
||
749 | * |
||
750 | * @return RecurrenceRule |
||
751 | */ |
||
752 | public function getRecurrenceRule() |
||
753 | { |
||
754 | @trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED); |
||
755 | |||
756 | return $this->recurrenceRule; |
||
757 | } |
||
758 | |||
759 | /** |
||
760 | * @param RecurrenceRule $recurrenceRule |
||
761 | * |
||
762 | * @return $this |
||
763 | */ |
||
764 | public function addRecurrenceRule(RecurrenceRule $recurrenceRule) |
||
765 | { |
||
766 | $this->recurrenceRules[] = $recurrenceRule; |
||
767 | |||
768 | return $this; |
||
769 | } |
||
770 | |||
771 | /** |
||
772 | * @return array |
||
773 | */ |
||
774 | public function getRecurrenceRules() |
||
775 | { |
||
776 | return $this->recurrenceRules; |
||
777 | } |
||
778 | |||
779 | /** |
||
780 | * @param $dtStamp |
||
781 | * |
||
782 | * @return $this |
||
783 | */ |
||
784 | public function setCreated($dtStamp) |
||
785 | { |
||
786 | $this->created = $dtStamp; |
||
787 | |||
788 | return $this; |
||
789 | } |
||
790 | |||
791 | /** |
||
792 | * @param $dtStamp |
||
793 | * |
||
794 | * @return $this |
||
795 | */ |
||
796 | public function setModified($dtStamp) |
||
797 | { |
||
798 | $this->modified = $dtStamp; |
||
799 | |||
800 | return $this; |
||
801 | } |
||
802 | |||
803 | /** |
||
804 | * @param $categories |
||
805 | * |
||
806 | * @return $this |
||
807 | */ |
||
808 | public function setCategories($categories) |
||
809 | { |
||
810 | $this->categories = $categories; |
||
811 | |||
812 | return $this; |
||
813 | } |
||
814 | |||
815 | /** |
||
816 | * Sets the event privacy. |
||
817 | * |
||
818 | * @param bool $flag |
||
819 | * |
||
820 | * @return $this |
||
821 | */ |
||
822 | public function setIsPrivate($flag) |
||
828 | |||
829 | /** |
||
830 | * @param \DateTimeInterface $dateTime |
||
831 | * |
||
832 | * @return \Eluceo\iCal\Component\Event |
||
833 | */ |
||
834 | public function addExDate(\DateTimeInterface $dateTime) |
||
835 | { |
||
836 | $this->exDates[] = $dateTime; |
||
837 | |||
838 | return $this; |
||
839 | } |
||
840 | |||
841 | /** |
||
842 | * @return \DateTimeInterface[] |
||
843 | */ |
||
844 | public function getExDates() |
||
845 | { |
||
846 | return $this->exDates; |
||
847 | } |
||
848 | |||
849 | /** |
||
850 | * @param \DateTimeInterface[] |
||
851 | * |
||
852 | * @return \Eluceo\iCal\Component\Event |
||
853 | */ |
||
854 | public function setExDates(array $exDates) |
||
855 | { |
||
856 | $this->exDates = $exDates; |
||
857 | |||
858 | return $this; |
||
859 | } |
||
860 | |||
861 | /** |
||
862 | * @return \Eluceo\iCal\Property\Event\RecurrenceId |
||
863 | */ |
||
864 | public function getRecurrenceId() |
||
865 | { |
||
866 | return $this->recurrenceId; |
||
867 | } |
||
868 | |||
869 | /** |
||
870 | * @param RecurrenceId $recurrenceId |
||
871 | * |
||
872 | * @return \Eluceo\iCal\Component\Event |
||
873 | */ |
||
874 | public function setRecurrenceId(RecurrenceId $recurrenceId) |
||
880 | } |
||
881 |