AbstractContactPointUpdated::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Events;
4
5
use CultuurNet\UDB3\ContactPoint;
6
7
abstract class AbstractContactPointUpdated extends AbstractEvent
8
{
9
    /**
10
     * @var ContactPoint
11
     */
12
    protected $contactPoint;
13
14
    final public function __construct(string $id, ContactPoint $contactPoint)
15
    {
16
        parent::__construct($id);
17
        $this->contactPoint = $contactPoint;
18
    }
19
20
    public function getContactPoint(): ContactPoint
21
    {
22
        return $this->contactPoint;
23
    }
24
25
    public function serialize(): array
26
    {
27
        return parent::serialize() + array(
28
            'contactPoint' => $this->contactPoint->serialize(),
29
        );
30
    }
31
32
    public static function deserialize(array $data): AbstractContactPointUpdated
33
    {
34
        return new static($data['item_id'], ContactPoint::deserialize($data['contactPoint']));
35
    }
36
}
37