Completed
Pull Request — master (#290)
by Luc
04:33
created

TitleUpdated::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

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