AbstractLabelEvent::getLabel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Events;
4
5
use CultuurNet\UDB3\Label;
6
use CultuurNet\UDB3\LabelEventInterface;
7
8
abstract class AbstractLabelEvent extends AbstractEvent implements LabelEventInterface
9
{
10
    /**
11
     * @var Label
12
     */
13
    protected $label;
14
15
    final public function __construct(string $itemId, Label $label)
16
    {
17
        parent::__construct($itemId);
18
        $this->label = $label;
19
    }
20
21
    public function getLabel(): Label
22
    {
23
        return $this->label;
24
    }
25
26
    public function serialize(): array
27
    {
28
        return parent::serialize() + array(
29
            'label' => (string) $this->label,
30
            'visibility' => $this->label->isVisible(),
31
        );
32
    }
33
34 View Code Duplication
    public static function deserialize(array $data): AbstractLabelEvent
0 ignored issues
show
Duplication introduced by
This method 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...
35
    {
36
        if (!isset($data['visibility'])) {
37
            $data['visibility'] = true;
38
        }
39
40
        return new static(
41
            $data['item_id'],
42
            new Label($data['label'], $data['visibility'])
43
        );
44
    }
45
}
46