AbstractTypicalAgeRangeUpdated::__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\Offer\AgeRange;
6
7
abstract class AbstractTypicalAgeRangeUpdated extends AbstractEvent
8
{
9
    /**
10
     * @var AgeRange
11
     */
12
    protected $typicalAgeRange;
13
14
    final public function __construct(string $id, AgeRange $typicalAgeRange)
15
    {
16
        parent::__construct($id);
17
        $this->typicalAgeRange = $typicalAgeRange;
18
    }
19
20
    public function getTypicalAgeRange(): AgeRange
21
    {
22
        return $this->typicalAgeRange;
23
    }
24
25
    public function serialize(): array
26
    {
27
        return parent::serialize() + array(
28
            'typicalAgeRange' => (string) $this->typicalAgeRange,
29
        );
30
    }
31
32
    public static function deserialize(array $data): AbstractTypicalAgeRangeUpdated
33
    {
34
        return new static($data['item_id'], AgeRange::fromString($data['typicalAgeRange']));
35
    }
36
}
37