Completed
Pull Request — master (#146)
by
unknown
01:33
created

Event::setMsBusyStatus()   A

Complexity

Conditions 5
Paths 2

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 5.9256

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 6
cts 9
cp 0.6667
rs 9.4555
c 0
b 0
f 0
cc 5
nc 2
nop 1
crap 5.9256
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(
464
                "The parameter 'geo' must be a string or an instance of " . Geo::class
465 1
                . " but an instance of {$className} was given."
466
            );
467
        }
468
469 2
        $this->location = $location;
470 2
        $this->locationTitle = $title;
471 2
        $this->locationGeo = $geo;
472
473 2
        return $this;
474
    }
475
476
    /**
477
     * @param Geo $geoProperty
478
     *
479
     * @return $this
480
     */
481 1
    public function setGeoLocation(Geo $geoProperty)
482
    {
483 1
        $this->locationGeo = $geoProperty;
484
485 1
        return $this;
486
    }
487
488
    /**
489
     * @param $noTime
490
     *
491
     * @return $this
492
     */
493 1
    public function setNoTime($noTime)
494
    {
495 1
        $this->noTime = $noTime;
496
497 1
        return $this;
498
    }
499
500
    /**
501
     * @param $msBusyStatus
502
     *
503
     * @return $this
504
     *
505
     * @throws \InvalidArgumentException
506
     */
507 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...
508
    {
509 2
        $msBusyStatus = strtoupper($msBusyStatus);
510 2
        if ($msBusyStatus == self::MS_BUSYSTATUS_FREE
511
            || $msBusyStatus == self::MS_BUSYSTATUS_TENTATIVE
512
            || $msBusyStatus == self::MS_BUSYSTATUS_BUSY
513 2
            || $msBusyStatus == self::MS_BUSYSTATUS_OOF
514
        ) {
515 2
            $this->msBusyStatus = $msBusyStatus;
516
        } else {
517
            throw new \InvalidArgumentException('Invalid value for status');
518
        }
519
520 2
        return $this;
521
    }
522
523
    /**
524
     * @return string|null
525
     */
526 1
    public function getMsBusyStatus()
527
    {
528 1
        return $this->msBusyStatus;
529
    }
530
531
    /**
532
     * @param int $sequence
533
     *
534
     * @return $this
535
     */
536 2
    public function setSequence($sequence)
537
    {
538 2
        $this->sequence = $sequence;
539
540 2
        return $this;
541
    }
542
543
    /**
544
     * @return int
545
     */
546 1
    public function getSequence()
547
    {
548 1
        return $this->sequence;
549
    }
550
551
    /**
552
     * @param Organizer $organizer
553
     *
554
     * @return $this
555
     */
556 2
    public function setOrganizer(Organizer $organizer)
557
    {
558 2
        $this->organizer = $organizer;
559
560 2
        return $this;
561
    }
562
563
    /**
564
     * @param $summary
565
     *
566
     * @return $this
567
     */
568 1
    public function setSummary($summary)
569
    {
570 1
        $this->summary = $summary;
571
572 1
        return $this;
573
    }
574
575
    /**
576
     * @param $uniqueId
577
     *
578
     * @return $this
579
     */
580 1
    public function setUniqueId($uniqueId)
581
    {
582 1
        $this->uniqueId = $uniqueId;
583
584 1
        return $this;
585
    }
586
587
    /**
588
     * @return string
589
     */
590 2
    public function getUniqueId()
591
    {
592 2
        return $this->uniqueId;
593
    }
594
595
    /**
596
     * @param $url
597
     *
598
     * @return $this
599
     */
600 1
    public function setUrl($url)
601
    {
602 1
        $this->url = $url;
603
604 1
        return $this;
605
    }
606
607
    /**
608
     * @param $useTimezone
609
     *
610
     * @return $this
611
     */
612
    public function setUseTimezone($useTimezone)
613
    {
614
        $this->useTimezone = $useTimezone;
615
616
        return $this;
617
    }
618
619
    /**
620
     * @return bool
621
     */
622
    public function getUseTimezone()
623
    {
624
        return $this->useTimezone;
625
    }
626
627
    /**
628
     * @param $timezoneString
629
     *
630
     * @return $this
631
     */
632 2
    public function setTimezoneString($timezoneString)
633
    {
634 2
        $this->timezoneString = $timezoneString;
635
636 2
        return $this;
637
    }
638
639
    /**
640
     * @return bool
641
     */
642 1
    public function getTimezoneString()
643
    {
644 1
        return $this->timezoneString;
645
    }
646
647
    /**
648
     * @param Attendees $attendees
649
     *
650
     * @return $this
651
     */
652
    public function setAttendees(Attendees $attendees)
653
    {
654
        $this->attendees = $attendees;
655
656
        return $this;
657
    }
658
659
    /**
660
     * @param string $attendee
661
     * @param array  $params
662
     *
663
     * @return $this
664
     */
665
    public function addAttendee($attendee, $params = [])
666
    {
667
        $this->attendees->add($attendee, $params);
668
669
        return $this;
670
    }
671
672
    /**
673
     * @return Attendees
674
     */
675
    public function getAttendees(): Attendees
676
    {
677
        return $this->attendees;
678
    }
679
680
    /**
681
     * @param $description
682
     *
683
     * @return $this
684
     */
685 4
    public function setDescription($description)
686
    {
687 4
        $this->description = $description;
688
689 4
        return $this;
690
    }
691
692
    /**
693
     * @param $descriptionHTML
694
     *
695
     * @return $this
696
     */
697
    public function setDescriptionHTML($descriptionHTML)
698
    {
699
        $this->descriptionHTML = $descriptionHTML;
700
701
        return $this;
702
    }
703
704
    /**
705
     * @param bool $useUtc
706
     *
707
     * @return $this
708
     */
709
    public function setUseUtc($useUtc = true)
710
    {
711
        $this->useUtc = $useUtc;
712
713
        return $this;
714
    }
715
716
    /**
717
     * @return string
718
     */
719
    public function getDescription()
720
    {
721
        return $this->description;
722
    }
723
724
    /**
725
     * @return string
726
     */
727
    public function getDescriptionHTML()
728
    {
729
        return $this->descriptionHTML;
730
    }
731
732
    /**
733
     * @param $status
734
     *
735
     * @return $this
736
     */
737
    public function setCancelled($status)
738
    {
739
        $this->cancelled = (bool) $status;
740
741
        return $this;
742
    }
743
744
    /**
745
     * @param $transparency
746
     *
747
     * @return $this
748
     *
749
     * @throws \InvalidArgumentException
750
     */
751 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...
752
    {
753
        $transparency = strtoupper($transparency);
754
        if ($transparency === self::TIME_TRANSPARENCY_OPAQUE
755
            || $transparency === self::TIME_TRANSPARENCY_TRANSPARENT
756
        ) {
757
            $this->transparency = $transparency;
758
        } else {
759
            throw new \InvalidArgumentException('Invalid value for transparancy');
760
        }
761
762
        return $this;
763
    }
764
765
    /**
766
     * @param $status
767
     *
768
     * @return $this
769
     *
770
     * @throws \InvalidArgumentException
771
     */
772 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...
773
    {
774
        $status = strtoupper($status);
775
        if ($status == self::STATUS_CANCELLED
776
            || $status == self::STATUS_CONFIRMED
777
            || $status == self::STATUS_TENTATIVE
778
        ) {
779
            $this->status = $status;
780
        } else {
781
            throw new \InvalidArgumentException('Invalid value for status');
782
        }
783
784
        return $this;
785
    }
786
787
    /**
788
     * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead.
789
     *
790
     * @param RecurrenceRule $recurrenceRule
791
     *
792
     * @return $this
793
     */
794
    public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
795
    {
796
        @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...
797
798
        $this->recurrenceRule = $recurrenceRule;
799
800
        return $this;
801
    }
802
803
    /**
804
     * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead.
805
     *
806
     * @return RecurrenceRule
807
     */
808
    public function getRecurrenceRule()
809
    {
810
        @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...
811
812
        return $this->recurrenceRule;
813
    }
814
815
    /**
816
     * @param RecurrenceRule $recurrenceRule
817
     *
818
     * @return $this
819
     */
820
    public function addRecurrenceRule(RecurrenceRule $recurrenceRule)
821
    {
822
        $this->recurrenceRules[] = $recurrenceRule;
823
824
        return $this;
825
    }
826
827
    /**
828
     * @return array
829
     */
830
    public function getRecurrenceRules()
831
    {
832
        return $this->recurrenceRules;
833
    }
834
835
    /**
836
     * @param $dtStamp
837
     *
838
     * @return $this
839
     */
840
    public function setCreated($dtStamp)
841
    {
842
        $this->created = $dtStamp;
843
844
        return $this;
845
    }
846
847
    /**
848
     * @param $dtStamp
849
     *
850
     * @return $this
851
     */
852
    public function setModified($dtStamp)
853
    {
854
        $this->modified = $dtStamp;
855
856
        return $this;
857
    }
858
859
    /**
860
     * @param $categories
861
     *
862
     * @return $this
863
     */
864
    public function setCategories($categories)
865
    {
866
        $this->categories = $categories;
867
868
        return $this;
869
    }
870
871
    /**
872
     * Sets the event privacy.
873
     *
874
     * @param bool $flag
875
     *
876
     * @return $this
877
     */
878
    public function setIsPrivate($flag)
879
    {
880
        $this->isPrivate = (bool) $flag;
881
882
        return $this;
883
    }
884
885
    /**
886
     * @param \DateTimeInterface $dateTime
887
     *
888
     * @return \Eluceo\iCal\Component\Event
889
     */
890
    public function addExDate(\DateTimeInterface $dateTime)
891
    {
892
        $this->exDates[] = $dateTime;
893
894
        return $this;
895
    }
896
897
    /**
898
     * @return \DateTimeInterface[]
899
     */
900
    public function getExDates()
901
    {
902
        return $this->exDates;
903
    }
904
905
    /**
906
     * @param \DateTimeInterface[]
907
     *
908
     * @return \Eluceo\iCal\Component\Event
909
     */
910
    public function setExDates(array $exDates)
911
    {
912
        $this->exDates = $exDates;
913
914
        return $this;
915
    }
916
917
    /**
918
     * @return \Eluceo\iCal\Property\Event\RecurrenceId
919
     */
920
    public function getRecurrenceId()
921
    {
922
        return $this->recurrenceId;
923
    }
924
925
    /**
926
     * @param RecurrenceId $recurrenceId
927
     *
928
     * @return \Eluceo\iCal\Component\Event
929
     */
930
    public function setRecurrenceId(RecurrenceId $recurrenceId)
931
    {
932
        $this->recurrenceId = $recurrenceId;
933
934
        return $this;
935
    }
936
937
    /**
938
     * @param array $attachment
939
     *
940
     * @return $this
941
     */
942 1
    public function addAttachment(Attachment $attachment)
943
    {
944 1
        $this->attachments[] = $attachment;
945
946 1
        return $this;
947
    }
948
949
    /**
950
     * @return array
951
     */
952
    public function getAttachments()
953
    {
954
        return $this->attachments;
955
    }
956
957
    /**
958
     * @param string $url
959
     */
960
    public function addUrlAttachment(string $url)
961
    {
962
        $this->addAttachment(new Attachment($url));
963
    }
964
}
965