|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CultuurNet\UDB3\Event\Events; |
|
4
|
|
|
|
|
5
|
|
|
use CultuurNet\UDB3\Calendar; |
|
6
|
|
|
use CultuurNet\UDB3\CalendarInterface; |
|
7
|
|
|
use CultuurNet\UDB3\Offer\Events\AbstractEvent; |
|
8
|
|
|
|
|
9
|
|
|
class EventCopied extends AbstractEvent |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
private $originalEventId; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var CalendarInterface|Calendar |
|
18
|
|
|
*/ |
|
19
|
|
|
private $calendar; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* EventCopied constructor. |
|
23
|
|
|
* @param string $eventId |
|
24
|
|
|
* @param string $originalEventId |
|
25
|
|
|
* @param CalendarInterface $calendar |
|
26
|
|
|
*/ |
|
27
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
28
|
|
|
$eventId, |
|
29
|
|
|
$originalEventId, |
|
30
|
|
|
CalendarInterface $calendar |
|
31
|
|
|
) { |
|
32
|
|
|
parent::__construct($eventId); |
|
33
|
|
|
|
|
34
|
|
|
if (!is_string($originalEventId)) { |
|
35
|
|
|
throw new \InvalidArgumentException( |
|
36
|
|
|
'Expected originalEventId to be a string, received ' . gettype($originalEventId) |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$this->originalEventId = $originalEventId; |
|
41
|
|
|
$this->calendar = $calendar; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getOriginalEventId() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->originalEventId; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return CalendarInterface |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getCalendar() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->calendar; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @inheritdoc |
|
62
|
|
|
*/ |
|
63
|
|
|
public function serialize() |
|
64
|
|
|
{ |
|
65
|
|
|
return parent::serialize() + [ |
|
66
|
|
|
'original_event_id' => $this->getOriginalEventId(), |
|
67
|
|
|
'calendar' => $this->calendar->serialize() |
|
|
|
|
|
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @inheritdoc |
|
73
|
|
|
*/ |
|
74
|
|
|
public static function deserialize(array $data) |
|
75
|
|
|
{ |
|
76
|
|
|
return new static( |
|
77
|
|
|
$data['item_id'], |
|
78
|
|
|
$data['original_event_id'], |
|
79
|
|
|
Calendar::deserialize($data['calendar']) |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
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.