Event::addAttendee()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
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\Component;
13
14
use Eluceo\iCal\Component;
15
use Eluceo\iCal\Property;
16
use Eluceo\iCal\Property\DateTimeProperty;
17
use Eluceo\iCal\Property\DateTimesProperty;
18
use Eluceo\iCal\Property\Event\Attachment;
19
use Eluceo\iCal\Property\Event\Attendees;
20
use Eluceo\iCal\Property\Event\Geo;
21
use Eluceo\iCal\Property\Event\Organizer;
22
use Eluceo\iCal\Property\Event\RecurrenceId;
23
use Eluceo\iCal\Property\Event\RecurrenceRule;
24
use Eluceo\iCal\Property\RawStringValue;
25
use Eluceo\iCal\PropertyBag;
26
27
/**
28
 * Implementation of the EVENT component.
29
 */
30
class Event extends Component
31
{
32
    const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
33
    const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT';
34
35
    const STATUS_TENTATIVE = 'TENTATIVE';
36
    const STATUS_CONFIRMED = 'CONFIRMED';
37
    const STATUS_CANCELLED = 'CANCELLED';
38
39
    const MS_BUSYSTATUS_FREE = 'FREE';
40
    const MS_BUSYSTATUS_TENTATIVE = 'TENTATIVE';
41
    const MS_BUSYSTATUS_BUSY = 'BUSY';
42
    const MS_BUSYSTATUS_OOF = 'OOF';
43
44
    /**
45
     * @var string
46
     */
47
    protected $uniqueId;
48
49
    /**
50
     * The property indicates the date/time that the instance of
51
     * the iCalendar object was created.
52
     *
53
     * The value MUST be specified in the UTC time format.
54
     *
55
     * @var \DateTime
56
     */
57
    protected $dtStamp;
58
59
    /**
60
     * @var \DateTime
61
     */
62
    protected $dtStart;
63
64
    /**
65
     * Preferentially chosen over the duration if both are set.
66
     *
67
     * @var \DateTime
68
     */
69
    protected $dtEnd;
70
71
    /**
72
     * @var \DateInterval
73
     */
74
    protected $duration;
75
76
    /**
77
     * @var bool
78
     */
79
    protected $noTime = false;
80
81
    /**
82
     * @var string
83
     */
84
    protected $msBusyStatus = null;
85
86
    /**
87
     * @var string
88
     */
89
    protected $url;
90
91
    /**
92
     * @var string
93
     */
94
    protected $location;
95
96
    /**
97
     * @var string
98
     */
99
    protected $locationTitle;
100
101
    /**
102
     * @var Geo
103
     */
104
    protected $locationGeo;
105
106
    /**
107
     * @var string
108
     */
109
    protected $summary;
110
111
    /**
112
     * @var Organizer
113
     */
114
    protected $organizer;
115
116
    /**
117
     * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7
118
     *
119
     * @var string
120
     */
121
    protected $transparency = self::TIME_TRANSPARENCY_OPAQUE;
122
123
    /**
124
     * If set to true the timezone will be added to the event.
125
     *
126
     * @var bool
127
     */
128
    protected $useTimezone = false;
129
130
    /**
131
     * If set will be used as the timezone identifier.
132
     *
133
     * @var string
134
     */
135
    protected $timezoneString = '';
136
137
    /**
138
     * @var int
139
     */
140
    protected $sequence = 0;
141
142
    /**
143
     * @var Attendees
144
     */
145
    protected $attendees;
146
147
    /**
148
     * @var string
149
     */
150
    protected $description;
151
152
    /**
153
     * @var string
154
     */
155
    protected $descriptionHTML;
156
157
    /**
158
     * @var string
159
     */
160
    protected $status;
161
162
    /**
163
     * @var RecurrenceRule
164
     */
165
    protected $recurrenceRule;
166
167
    /**
168
     * @var array
169
     */
170
    protected $recurrenceRules = [];
171
172
    /**
173
     * This property specifies the date and time that the calendar
174
     * information was created.
175
     *
176
     * The value MUST be specified in the UTC time format.
177
     *
178
     * @var \DateTime
179
     */
180
    protected $created;
181
182
    /**
183
     * The property specifies the date and time that the information
184
     * associated with the calendar component was last revised.
185
     *
186
     * The value MUST be specified in the UTC time format.
187
     *
188
     * @var \DateTime
189
     */
190
    protected $modified;
191
192
    /**
193
     * Indicates if the UTC time should be used or not.
194
     *
195
     * @var bool
196
     */
197
    protected $useUtc = true;
198
199
    /**
200
     * @var bool
201
     */
202
    protected $cancelled;
203
204
    /**
205
     * This property is used to specify categories or subtypes
206
     * of the calendar component.  The categories are useful in searching
207
     * for a calendar component of a particular type and category.
208
     *
209
     * @see https://tools.ietf.org/html/rfc5545#section-3.8.1.2
210
     *
211
     * @var array
212
     */
213
    protected $categories;
214
215
    /**
216
     * https://tools.ietf.org/html/rfc5545#section-3.8.1.3.
217
     *
218
     * @var bool
219
     */
220
    protected $isPrivate = false;
221
222
    /**
223
     * Dates to be excluded from a series of events.
224
     *
225
     * @var \DateTimeInterface[]
226
     */
227
    protected $exDates = [];
228
229
    /**
230
     * @var RecurrenceId
231
     */
232
    protected $recurrenceId;
233
234
    /**
235
     * @var Attachment[]
236
     */
237
    protected $attachments = [];
238
239 28
    public function __construct(string $uniqueId = null)
240
    {
241 28
        if (null == $uniqueId) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $uniqueId of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
242 4
            $uniqueId = uniqid();
243
        }
244
245 28
        $this->uniqueId = $uniqueId;
246 28
        $this->attendees = new Attendees();
247 28
    }
248
249
    /**
250
     * {@inheritdoc}
251
     */
252 7
    public function getType()
253
    {
254 7
        return 'VEVENT';
255
    }
256
257
    /**
258
     * {@inheritdoc}
259
     */
260 18
    public function buildPropertyBag()
261
    {
262 18
        $propertyBag = new PropertyBag();
263
264
        // mandatory information
265 18
        $propertyBag->set('UID', $this->uniqueId);
266
267 18
        $propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
268 18
        $propertyBag->set('SEQUENCE', $this->sequence);
269 18
        $propertyBag->set('TRANSP', $this->transparency);
270
271 18
        if ($this->status) {
272
            $propertyBag->set('STATUS', $this->status);
273
        }
274
275
        // An event can have a 'dtend' or 'duration', but not both.
276 18
        if ($this->dtEnd !== null) {
277 4
            $dtEnd = clone $this->dtEnd;
278 4
            if ($this->noTime === true) {
279
                $dtEnd = $dtEnd->add(new \DateInterval('P1D'));
280
            }
281 4
            $propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
282 14
        } elseif ($this->duration !== null) {
283 1
            $propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS'));
284
        }
285
286
        // optional information
287 18
        if (null != $this->url) {
288 1
            $propertyBag->set('URL', $this->url);
289
        }
290
291 18
        if (null != $this->location) {
292 2
            $propertyBag->set('LOCATION', $this->location);
293
294 2
            if (null != $this->locationGeo) {
295 1
                $propertyBag->add(
296 1
                    new Property(
297 1
                        'X-APPLE-STRUCTURED-LOCATION',
298 1
                        new RawStringValue('geo:' . $this->locationGeo->getGeoLocationAsString(',')),
299
                        [
300 1
                            'VALUE' => 'URI',
301 1
                            'X-ADDRESS' => $this->location,
302 1
                            'X-APPLE-RADIUS' => 49,
303 1
                            'X-TITLE' => $this->locationTitle,
304
                        ]
305
                    )
306
                );
307
            }
308
        }
309
310 18
        if (null != $this->locationGeo) {
311 2
            $propertyBag->add($this->locationGeo);
312
        }
313
314 18
        if (null != $this->summary) {
315 1
            $propertyBag->set('SUMMARY', $this->summary);
316
        }
317
318 18
        if (null != $this->attendees) {
319 18
            $propertyBag->add($this->attendees);
320
        }
321
322 18
        $propertyBag->set('CLASS', $this->isPrivate ? 'PRIVATE' : 'PUBLIC');
323
324 18
        if (null != $this->description) {
325 4
            $propertyBag->set('DESCRIPTION', $this->description);
326
        }
327
328 18
        if (null != $this->descriptionHTML) {
329
            $propertyBag->add(
330
                new Property(
331
                    'X-ALT-DESC',
332
                    $this->descriptionHTML,
333
                    [
334
                        'FMTTYPE' => 'text/html',
335
                    ]
336
                )
337
            );
338
        }
339
340 18
        if (null != $this->recurrenceRule) {
341
            $propertyBag->set('RRULE', $this->recurrenceRule);
342
        }
343
344 18
        foreach ($this->recurrenceRules as $recurrenceRule) {
345
            $propertyBag->set('RRULE', $recurrenceRule);
346
        }
347
348 18
        if (null != $this->recurrenceId) {
349
            $this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString);
350
            $propertyBag->add($this->recurrenceId);
351
        }
352
353 18
        if (!empty($this->exDates)) {
354
            $propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
355
        }
356
357 18
        if ($this->cancelled) {
358
            $propertyBag->set('STATUS', 'CANCELLED');
359
        }
360
361 18
        if (null != $this->organizer) {
362 2
            $propertyBag->add($this->organizer);
363
        }
364
365 18
        if ($this->noTime) {
366 1
            $propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
367
        }
368
369 18
        if (null != $this->msBusyStatus) {
370 1
            $propertyBag->set('X-MICROSOFT-CDO-BUSYSTATUS', $this->msBusyStatus);
371 1
            $propertyBag->set('X-MICROSOFT-CDO-INTENDEDSTATUS', $this->msBusyStatus);
372
        }
373
374 18
        if (null != $this->categories) {
375
            $propertyBag->set('CATEGORIES', $this->categories);
376
        }
377
378 18
        $propertyBag->add(
379 18
            new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTimeImmutable(), false, false, true)
380
        );
381
382 18
        if ($this->created) {
383
            $propertyBag->add(new DateTimeProperty('CREATED', $this->created, false, false, true));
384
        }
385
386 18
        if ($this->modified) {
387
            $propertyBag->add(new DateTimeProperty('LAST-MODIFIED', $this->modified, false, false, true));
388
        }
389
390 18
        foreach ($this->attachments as $attachment) {
391
            $propertyBag->add($attachment);
392
        }
393
394 18
        return $propertyBag;
395
    }
396
397
    /**
398
     * @param $dtEnd
399
     *
400
     * @return $this
401
     */
402 5
    public function setDtEnd($dtEnd)
403
    {
404 5
        $this->dtEnd = $dtEnd;
405
406 5
        return $this;
407
    }
408
409 2
    public function getDtEnd()
410
    {
411 2
        return $this->dtEnd;
412
    }
413
414 5
    public function setDtStart($dtStart)
415
    {
416 5
        $this->dtStart = $dtStart;
417
418 5
        return $this;
419
    }
420
421 2
    public function getDtStart()
422
    {
423 2
        return $this->dtStart;
424
    }
425
426
    /**
427
     * @param $dtStamp
428
     *
429
     * @return $this
430
     */
431 1
    public function setDtStamp($dtStamp)
432
    {
433 1
        $this->dtStamp = $dtStamp;
434
435 1
        return $this;
436
    }
437
438
    /**
439
     * @param $duration
440
     *
441
     * @return $this
442
     */
443 1
    public function setDuration($duration)
444
    {
445 1
        $this->duration = $duration;
446
447 1
        return $this;
448
    }
449
450
    /**
451
     * @param string     $location
452
     * @param string     $title
453
     * @param Geo|string $geo
454
     *
455
     * @return $this
456
     */
457 3
    public function setLocation($location, $title = '', $geo = null)
458
    {
459 3
        if (is_scalar($geo)) {
460 1
            $geo = Geo::fromString($geo);
0 ignored issues
show
Deprecated Code introduced by
The method Eluceo\iCal\Property\Event\Geo::fromString() has been deprecated with message: This method is used to allow backwards compatibility for Event::setLocation

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
461 2
        } elseif (!is_null($geo) && !$geo instanceof Geo) {
462 1
            $className = get_class($geo);
463 1
            throw new \InvalidArgumentException("The parameter 'geo' must be a string or an instance of " . Geo::class . " but an instance of {$className} was given.");
464
        }
465
466 2
        $this->location = $location;
467 2
        $this->locationTitle = $title;
468 2
        $this->locationGeo = $geo;
469
470 2
        return $this;
471
    }
472
473
    /**
474
     * @return $this
475
     */
476 1
    public function setGeoLocation(Geo $geoProperty)
477
    {
478 1
        $this->locationGeo = $geoProperty;
479
480 1
        return $this;
481
    }
482
483
    /**
484
     * @param $noTime
485
     *
486
     * @return $this
487
     */
488 1
    public function setNoTime($noTime)
489
    {
490 1
        $this->noTime = $noTime;
491
492 1
        return $this;
493
    }
494
495
    /**
496
     * @param $msBusyStatus
497
     *
498
     * @return $this
499
     *
500
     * @throws \InvalidArgumentException
501
     */
502 2 View Code Duplication
    public function setMsBusyStatus($msBusyStatus)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
503
    {
504 2
        $msBusyStatus = strtoupper($msBusyStatus);
505 2
        if ($msBusyStatus == self::MS_BUSYSTATUS_FREE
506
            || $msBusyStatus == self::MS_BUSYSTATUS_TENTATIVE
507
            || $msBusyStatus == self::MS_BUSYSTATUS_BUSY
508 2
            || $msBusyStatus == self::MS_BUSYSTATUS_OOF
509
        ) {
510 2
            $this->msBusyStatus = $msBusyStatus;
511
        } else {
512
            throw new \InvalidArgumentException('Invalid value for status');
513
        }
514
515 2
        return $this;
516
    }
517
518
    /**
519
     * @return string|null
520
     */
521 1
    public function getMsBusyStatus()
522
    {
523 1
        return $this->msBusyStatus;
524
    }
525
526
    /**
527
     * @param int $sequence
528
     *
529
     * @return $this
530
     */
531 2
    public function setSequence($sequence)
532
    {
533 2
        $this->sequence = $sequence;
534
535 2
        return $this;
536
    }
537
538
    /**
539
     * @return int
540
     */
541 1
    public function getSequence()
542
    {
543 1
        return $this->sequence;
544
    }
545
546
    /**
547
     * @return $this
548
     */
549 2
    public function setOrganizer(Organizer $organizer)
550
    {
551 2
        $this->organizer = $organizer;
552
553 2
        return $this;
554
    }
555
556
    /**
557
     * @param $summary
558
     *
559
     * @return $this
560
     */
561 1
    public function setSummary($summary)
562
    {
563 1
        $this->summary = $summary;
564
565 1
        return $this;
566
    }
567
568
    /**
569
     * @param $uniqueId
570
     *
571
     * @return $this
572
     */
573 1
    public function setUniqueId($uniqueId)
574
    {
575 1
        $this->uniqueId = $uniqueId;
576
577 1
        return $this;
578
    }
579
580
    /**
581
     * @return string
582
     */
583 2
    public function getUniqueId()
584
    {
585 2
        return $this->uniqueId;
586
    }
587
588
    /**
589
     * @param $url
590
     *
591
     * @return $this
592
     */
593 1
    public function setUrl($url)
594
    {
595 1
        $this->url = $url;
596
597 1
        return $this;
598
    }
599
600
    /**
601
     * @param $useTimezone
602
     *
603
     * @return $this
604
     */
605
    public function setUseTimezone($useTimezone)
606
    {
607
        $this->useTimezone = $useTimezone;
608
609
        return $this;
610
    }
611
612
    /**
613
     * @return bool
614
     */
615
    public function getUseTimezone()
616
    {
617
        return $this->useTimezone;
618
    }
619
620
    /**
621
     * @param $timezoneString
622
     *
623
     * @return $this
624
     */
625 2
    public function setTimezoneString($timezoneString)
626
    {
627 2
        $this->timezoneString = $timezoneString;
628
629 2
        return $this;
630
    }
631
632
    /**
633
     * @return bool
634
     */
635 1
    public function getTimezoneString()
636
    {
637 1
        return $this->timezoneString;
638
    }
639
640
    /**
641
     * @return $this
642
     */
643
    public function setAttendees(Attendees $attendees)
644
    {
645
        $this->attendees = $attendees;
646
647
        return $this;
648
    }
649
650
    /**
651
     * @param string $attendee
652
     * @param array  $params
653
     *
654
     * @return $this
655
     */
656
    public function addAttendee($attendee, $params = [])
657
    {
658
        $this->attendees->add($attendee, $params);
659
660
        return $this;
661
    }
662
663
    public function getAttendees(): Attendees
664
    {
665
        return $this->attendees;
666
    }
667
668
    /**
669
     * @param $description
670
     *
671
     * @return $this
672
     */
673 4
    public function setDescription($description)
674
    {
675 4
        $this->description = $description;
676
677 4
        return $this;
678
    }
679
680
    /**
681
     * @param $descriptionHTML
682
     *
683
     * @return $this
684
     */
685
    public function setDescriptionHTML($descriptionHTML)
686
    {
687
        $this->descriptionHTML = $descriptionHTML;
688
689
        return $this;
690
    }
691
692
    /**
693
     * @param bool $useUtc
694
     *
695
     * @return $this
696
     */
697
    public function setUseUtc($useUtc = true)
698
    {
699
        $this->useUtc = $useUtc;
700
701
        return $this;
702
    }
703
704
    /**
705
     * @return string
706
     */
707
    public function getDescription()
708
    {
709
        return $this->description;
710
    }
711
712
    /**
713
     * @return string
714
     */
715
    public function getDescriptionHTML()
716
    {
717
        return $this->descriptionHTML;
718
    }
719
720
    /**
721
     * @param $status
722
     *
723
     * @return $this
724
     */
725
    public function setCancelled($status)
726
    {
727
        $this->cancelled = (bool) $status;
728
729
        return $this;
730
    }
731
732
    /**
733
     * @param $transparency
734
     *
735
     * @return $this
736
     *
737
     * @throws \InvalidArgumentException
738
     */
739 View Code Duplication
    public function setTimeTransparency($transparency)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
740
    {
741
        $transparency = strtoupper($transparency);
742
        if ($transparency === self::TIME_TRANSPARENCY_OPAQUE
743
            || $transparency === self::TIME_TRANSPARENCY_TRANSPARENT
744
        ) {
745
            $this->transparency = $transparency;
746
        } else {
747
            throw new \InvalidArgumentException('Invalid value for transparancy');
748
        }
749
750
        return $this;
751
    }
752
753
    /**
754
     * @param $status
755
     *
756
     * @return $this
757
     *
758
     * @throws \InvalidArgumentException
759
     */
760 View Code Duplication
    public function setStatus($status)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
761
    {
762
        $status = strtoupper($status);
763
        if ($status == self::STATUS_CANCELLED
764
            || $status == self::STATUS_CONFIRMED
765
            || $status == self::STATUS_TENTATIVE
766
        ) {
767
            $this->status = $status;
768
        } else {
769
            throw new \InvalidArgumentException('Invalid value for status');
770
        }
771
772
        return $this;
773
    }
774
775
    /**
776
     * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead.
777
     *
778
     * @return $this
779
     */
780
    public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
781
    {
782
        @trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
783
784
        $this->recurrenceRule = $recurrenceRule;
785
786
        return $this;
787
    }
788
789
    /**
790
     * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead.
791
     *
792
     * @return RecurrenceRule
793
     */
794
    public function getRecurrenceRule()
795
    {
796
        @trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
797
798
        return $this->recurrenceRule;
799
    }
800
801
    /**
802
     * @return $this
803
     */
804
    public function addRecurrenceRule(RecurrenceRule $recurrenceRule)
805
    {
806
        $this->recurrenceRules[] = $recurrenceRule;
807
808
        return $this;
809
    }
810
811
    /**
812
     * @return array
813
     */
814
    public function getRecurrenceRules()
815
    {
816
        return $this->recurrenceRules;
817
    }
818
819
    /**
820
     * @param $dtStamp
821
     *
822
     * @return $this
823
     */
824
    public function setCreated($dtStamp)
825
    {
826
        $this->created = $dtStamp;
827
828
        return $this;
829
    }
830
831
    /**
832
     * @param $dtStamp
833
     *
834
     * @return $this
835
     */
836
    public function setModified($dtStamp)
837
    {
838
        $this->modified = $dtStamp;
839
840
        return $this;
841
    }
842
843
    /**
844
     * @param $categories
845
     *
846
     * @return $this
847
     */
848
    public function setCategories($categories)
849
    {
850
        $this->categories = $categories;
851
852
        return $this;
853
    }
854
855
    /**
856
     * Sets the event privacy.
857
     *
858
     * @param bool $flag
859
     *
860
     * @return $this
861
     */
862
    public function setIsPrivate($flag)
863
    {
864
        $this->isPrivate = (bool) $flag;
865
866
        return $this;
867
    }
868
869
    /**
870
     * @return \Eluceo\iCal\Component\Event
871
     */
872
    public function addExDate(\DateTimeInterface $dateTime)
873
    {
874
        $this->exDates[] = $dateTime;
875
876
        return $this;
877
    }
878
879
    /**
880
     * @return \DateTimeInterface[]
881
     */
882
    public function getExDates()
883
    {
884
        return $this->exDates;
885
    }
886
887
    /**
888
     * @param \DateTimeInterface[]
889
     *
890
     * @return \Eluceo\iCal\Component\Event
891
     */
892
    public function setExDates(array $exDates)
893
    {
894
        $this->exDates = $exDates;
895
896
        return $this;
897
    }
898
899
    /**
900
     * @return \Eluceo\iCal\Property\Event\RecurrenceId
901
     */
902
    public function getRecurrenceId()
903
    {
904
        return $this->recurrenceId;
905
    }
906
907
    /**
908
     * @return \Eluceo\iCal\Component\Event
909
     */
910
    public function setRecurrenceId(RecurrenceId $recurrenceId)
911
    {
912
        $this->recurrenceId = $recurrenceId;
913
914
        return $this;
915
    }
916
917
    /**
918
     * @param array $attachment
919
     *
920
     * @return $this
921
     */
922 1
    public function addAttachment(Attachment $attachment)
923
    {
924 1
        $this->attachments[] = $attachment;
925
926 1
        return $this;
927
    }
928
929
    /**
930
     * @return array
931
     */
932
    public function getAttachments()
933
    {
934
        return $this->attachments;
935
    }
936
937
    public function addUrlAttachment(string $url)
938
    {
939
        $this->addAttachment(new Attachment($url));
940
    }
941
}
942