Code Duplication    Length = 48-52 lines in 2 locations

src/Offer/Events/AbstractDescriptionTranslated.php 1 location

@@ 8-55 (lines=48) @@
5
use CultuurNet\UDB3\Description;
6
use CultuurNet\UDB3\Language;
7
8
class AbstractDescriptionTranslated extends AbstractPropertyTranslatedEvent
9
{
10
    /**
11
     * @var Description
12
     */
13
    protected $description;
14
15
    /**
16
     * @param string $itemId
17
     * @param Language $language
18
     * @param Description $description
19
     */
20
    public function __construct($itemId, Language $language, Description $description)
21
    {
22
        parent::__construct($itemId, $language);
23
        $this->description = $description;
24
    }
25
26
    /**
27
     * @return Description
28
     */
29
    public function getDescription()
30
    {
31
        return $this->description;
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function serialize()
38
    {
39
        return parent::serialize() + array(
40
            'description' => $this->description->toNative(),
41
        );
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public static function deserialize(array $data)
48
    {
49
        return new static(
50
            $data['item_id'],
51
            new Language($data['language']),
52
            new Description($data['description'])
53
        );
54
    }
55
}
56

src/Organizer/Events/AddressTranslated.php 1 location

@@ 8-59 (lines=52) @@
5
use CultuurNet\UDB3\Address\Address;
6
use CultuurNet\UDB3\Language;
7
8
class AddressTranslated extends AddressUpdated
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