AbstractTypicalAgeRangeUpdated   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getTypicalAgeRange() 0 4 1
A serialize() 0 6 1
A deserialize() 0 4 1
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