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

Event::createdAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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