Completed
Push — master ( c63c12...520404 )
by Frank
03:37 queued 01:34
created

VersionTwo::fromPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace With\Versioned\Event;
4
5
use EventSauce\EventSourcing\AggregateRootId;
6
use EventSauce\EventSourcing\Command;
7
use EventSauce\EventSourcing\Event;
8
use EventSauce\EventSourcing\PointInTime;
9
10
final class VersionTwo implements Event
11
{
12
    /**
13
     * @var AggregateRootId
14
     */
15
    private $aggregateRootId;
16
17
    /**
18
     * @var PointInTime
19
     */
20
    private $timeOfRecording;
21
22
    public function __construct(
23
        AggregateRootId $aggregateRootId,
24
        PointInTime $timeOfRecording
25
    ) {
26
        $this->aggregateRootId = $aggregateRootId;
27
        $this->timeOfRecording = $timeOfRecording;
28
    }
29
30
    public function aggregateRootId(): AggregateRootId
31
    {
32
        return $this->aggregateRootId;
33
    }
34
35
    public function eventVersion(): int
36
    {
37
        return 2;
38
    }
39
    
40
    public function timeOfRecording(): PointInTime
41
    {
42
        return $this->timeOfRecording;
43
    }
44
45
    public static function fromPayload(
46
        array $payload,
47
        AggregateRootId $aggregateRootId,
48
        PointInTime $timeOfRecording): Event
49
    {
50
        return new VersionTwo(
51
            $aggregateRootId,
52
            $timeOfRecording
53
        );
54
    }
55
56
    public function toPayload(): array
57
    {
58
        return [];
59
    }
60
61
    public static function with(AggregateRootId $aggregateRootId, PointInTime $timeOfRecording): VersionTwo
62
    {
63
        return new VersionTwo(
64
            $aggregateRootId,
65
            $timeOfRecording
66
        );
67
    }
68
69
}
70
71
72