AbstractEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getItemId() 0 4 1
A serialize() 0 6 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