AbstractEvent::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Events;
4
5
use Broadway\Serializer\SerializableInterface;
6
7
abstract class AbstractEvent implements SerializableInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $itemId;
13
14
    public function __construct(string $itemId)
15
    {
16
        if (!is_string($itemId)) {
17
            throw new \InvalidArgumentException(
18
                'Expected itemId to be a string, received ' . gettype($itemId)
19
            );
20
        }
21
22
        $this->itemId = $itemId;
23
    }
24
25
    public function getItemId(): string
26
    {
27
        return $this->itemId;
28
    }
29
30
    public function serialize(): array
31
    {
32
        return array(
33
            'item_id' => $this->itemId,
34
        );
35
    }
36
}
37