1 | <?php |
||
6 | class Event implements EventInterface |
||
7 | { |
||
8 | /** @var string */ |
||
9 | private $name; |
||
10 | |||
11 | /** @var string|object|null */ |
||
12 | private $target; |
||
13 | |||
14 | /** @var array */ |
||
15 | private $params; |
||
16 | |||
17 | /** @var bool */ |
||
18 | private $isPropagationStopped; |
||
19 | |||
20 | /** |
||
21 | * @param string $name |
||
22 | * @param string|object|null $target |
||
23 | * @param array $params |
||
24 | */ |
||
25 | 24 | public function __construct(string $name, $target = null, array $params = []) |
|
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | 11 | public function getName(): string |
|
40 | |||
41 | /** |
||
42 | * @inheritdoc |
||
43 | */ |
||
44 | 3 | public function getTarget() |
|
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | 3 | public function getParams(): array |
|
56 | |||
57 | /** |
||
58 | * @inheritdoc |
||
59 | */ |
||
60 | 3 | public function getParam(string $name) |
|
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | 1 | public function setName(string $name) |
|
73 | { |
||
74 | 1 | if (!is_string($name)) { |
|
75 | throw new \InvalidArgumentException('$name must be a string.'); |
||
76 | } |
||
77 | |||
78 | 1 | $this->name = $name; |
|
79 | 1 | } |
|
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | 1 | public function setTarget($target) |
|
88 | |||
89 | /** |
||
90 | * @inheritdoc |
||
91 | */ |
||
92 | 1 | public function setParams(array $params) |
|
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | */ |
||
100 | 2 | public function stopPropagation(bool $flag) |
|
101 | { |
||
102 | 2 | if (!is_bool($flag)) { |
|
103 | throw new \InvalidArgumentException('$flag must be a bool.'); |
||
104 | } |
||
105 | |||
106 | 2 | $this->isPropagationStopped = $flag; |
|
107 | 2 | } |
|
108 | |||
109 | /** |
||
110 | * @inheritdoc |
||
111 | */ |
||
112 | 8 | public function isPropagationStopped(): bool |
|
116 | } |
||
117 |