Completed
Pull Request — master (#306)
by Luc
07:37
created

TitleTranslated::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

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