Completed
Push — master ( fa909b...9344a1 )
by Beñat
01:48
created

StoredEvent::occurredOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Shared Kernel library.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\SharedKernel\Event;
13
14
use LIN3S\SharedKernel\Domain\Model\DomainEvent;
15
use LIN3S\SharedKernel\Domain\Model\DomainEventCollection;
16
use LIN3S\SharedKernel\Domain\Model\Identity\Id;
17
18
/**
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
class StoredEvent implements DomainEvent
22
{
23
    private $id;
0 ignored issues
show
Unused Code introduced by
The property $id is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24
    private $type;
25
    private $payload;
26
    private $occurredOn;
27
    private $streamName;
28
29
    public function __construct($type, $payload, \DateTimeInterface $occurredOn, StreamName $streamName)
30
    {
31
        $this->type = $type;
32
        $this->payload = $payload;
33
        $this->occurredOn = $this->setOccurredOn($occurredOn);
34
        $this->streamName = $streamName->name();
35
    }
36
37
    private function setOccurredOn(\DateTimeInterface $occurredOn)
38
    {
39
        return (new \DateTimeImmutable($occurredOn->format('Y-m-d H:m:s'), new \DateTimeZone('UTC')))->getTimestamp();
40
    }
41
42
    public function occurredOn()
43
    {
44
        return $this->occurredOn;
45
    }
46
}
47