AbstractTitleUpdated::deserialize()   A
last analyzed

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 CultuurNet\UDB3\Title;
6
7 View Code Duplication
abstract class AbstractTitleUpdated extends AbstractEvent
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 Title
11
     */
12
    protected $title;
13
14
    final public function __construct(string $id, Title $title)
15
    {
16
        parent::__construct($id);
17
        $this->title = $title;
18
    }
19
20
    public function getTitle(): Title
21
    {
22
        return $this->title;
23
    }
24
25
    public function serialize(): array
26
    {
27
        return parent::serialize() + array(
28
            'title' => (string) $this->title,
29
        );
30
    }
31
32
    public static function deserialize(array $data): AbstractTitleUpdated
33
    {
34
        return new static($data['item_id'], new Title($data['title']));
35
    }
36
}
37