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
|
|
|
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
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: