Completed
Push — test-php74 ( a9c69c...14570c )
by Markus
04:42 queued 03:08
created

Event   F

Complexity

Total Complexity 84

Size/Duplication

Total Lines 866
Duplicated Lines 1.5 %

Coupling/Cohesion

Components 1
Dependencies 10

Test Coverage

Coverage 54.95%

Importance

Changes 0
Metric Value
wmc 84
lcom 1
cbo 10
dl 13
loc 866
ccs 122
cts 222
cp 0.5495
rs 1.734
c 0
b 0
f 0

50 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getType() 0 4 1
F buildPropertyBag() 0 131 26
A setDtEnd() 0 6 1
A getDtEnd() 0 4 1
A setDtStart() 0 6 1
A getDtStart() 0 4 1
A setDtStamp() 0 6 1
A setDuration() 0 6 1
A setLocation() 0 15 4
A setGeoLocation() 0 6 1
A setNoTime() 0 6 1
A setSequence() 0 6 1
A getSequence() 0 4 1
A setOrganizer() 0 6 1
A setSummary() 0 6 1
A setUniqueId() 0 6 1
A getUniqueId() 0 4 1
A setUrl() 0 6 1
A setUseTimezone() 0 6 1
A getUseTimezone() 0 4 1
A setTimezoneString() 0 6 1
A getTimezoneString() 0 4 1
A setAttendees() 0 6 1
A addAttendee() 0 6 1
A getAttendees() 0 4 1
A setDescription() 0 6 1
A setDescriptionHTML() 0 6 1
A setUseUtc() 0 6 1
A getDescription() 0 4 1
A getDescriptionHTML() 0 4 1
A setCancelled() 0 6 1
A setTimeTransparency() 13 13 3
A setStatus() 0 14 4
A setRecurrenceRule() 0 8 1
A getRecurrenceRule() 0 6 1
A addRecurrenceRule() 0 6 1
A getRecurrenceRules() 0 4 1
A setCreated() 0 6 1
A setModified() 0 6 1
A setCategories() 0 6 1
A setIsPrivate() 0 6 1
A addExDate() 0 6 1
A getExDates() 0 4 1
A setExDates() 0 6 1
A getRecurrenceId() 0 4 1
A setRecurrenceId() 0 6 1
A addAttachment() 0 6 1
A getAttachments() 0 4 1
A addUrlAttachment() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

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 Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

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