Completed
Pull Request — master (#393)
by Luc
14:43
created

AddressTranslated::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

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