Completed
Pull Request — master (#473)
by
unknown
02:11
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 View Code Duplication
abstract class AbstractEvent implements SerializableInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $itemId;
13
14
    /**
15
     * @param $itemId
16
     *  The id of the item that is the subject of the event.
17
     */
18
    public function __construct($itemId)
19
    {
20
        if (!is_string($itemId)) {
21
            throw new \InvalidArgumentException(
22
                'Expected itemId to be a string, received ' . gettype($itemId)
23
            );
24
        }
25
26
        $this->itemId = $itemId;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getItemId()
33
    {
34
        return $this->itemId;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function serialize()
41
    {
42
        return array(
43
            'item_id' => $this->itemId,
44
        );
45
    }
46
}
47