AbstractLabelEvent::deserialize()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

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