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

UrlUpdated::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 ValueObjects\Web\Url;
6
7 View Code Duplication
class UrlUpdated 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 Url
11
     */
12
    private $url;
13
14
    /**
15
     * UrlUpdated constructor.
16
     * @param string $organizerId
17
     * @param Url $url
18
     */
19
    public function __construct(
20
        $organizerId,
21
        Url $url
22
    ) {
23
        parent::__construct($organizerId);
24
        $this->url = $url;
25
    }
26
27
    /**
28
     * @return Url
29
     */
30
    public function getUrl()
31
    {
32
        return $this->url;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function serialize()
39
    {
40
        return parent::serialize() + [
41
                'url' => (string) $this->getUrl()
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
            Url::fromNative($data['url'])
54
        );
55
    }
56
}
57