Completed
Pull Request — master (#239)
by Luc
05:18
created

AbstractLabelEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace CultuurNet\UDB3\Organizer\Events;
4
5
use CultuurNet\UDB3\Label;
6
7
abstract class AbstractLabelEvent extends OrganizerEvent
8
{
9
    /**
10
     * @var Label
11
     */
12
    private $label;
13
14
    /**
15
     * @param string $organizerId
16
     * @param Label $label
17
     */
18
    public function __construct(
19
        $organizerId,
20
        Label $label
21
    ) {
22
        parent::__construct($organizerId);
23
        $this->label = $label;
24
    }
25
26
    /**
27
     * @return Label
28
     */
29
    public function getLabel()
30
    {
31
        return $this->label;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public static function deserialize(array $data)
38
    {
39
        return new static(
40
            $data['organizer_id'],
41
            new Label($data['label'])
42
        );
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function serialize()
49
    {
50
        return parent::serialize() + [
51
            'label' => (string) $this->label
52
        ];
53
    }
54
}
55