Completed
Push — master ( d252f0...d75c62 )
by Jonas
22s queued 11s
created

AbstractEvent::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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