Completed
Push — master ( d5a496...915902 )
by Tomasz
01:58
created

Event   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getVersion() 0 3 1
A createdAt() 0 3 1
A getPayload() 0 3 1
A getName() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Aggrego\Domain\Shared\Event\Model\Events;
6
7
use Aggrego\Domain\Api\Application\Event\Event as EventInterface;
8
use DateTime;
9
10
abstract class Event implements EventInterface
11
{
12
    private const DEFAULT_VERSION = '1.0.0';
13
14
    /** @var array */
15
    private $payload;
16
17
    /** @var string */
18
    private $version;
19
20
    /** @var DateTime */
21
    private $createdAt;
22
23
    public function __construct(array $payload, string $version = self::DEFAULT_VERSION)
24
    {
25
        $this->payload = $payload;
26
        $this->version = $version;
27
        $this->createdAt = new DateTime();
28
    }
29
30
    public function getName(): string
31
    {
32
        return static::class;
33
    }
34
35
    public function getPayload(): array
36
    {
37
        return $this->payload;
38
    }
39
40
    public function getVersion(): string
41
    {
42
        return $this->version;
43
    }
44
45
    public function createdAt(): string
46
    {
47
        return $this->createdAt->format(DateTime::ATOM);
48
    }
49
}
50