AbstractDomainEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A whenHappened() 0 4 1
A getPayload() 0 4 1
A setParam() 0 4 1
1
<?php
2
/**
3
 * Copyright
4
 */
5
namespace Hexarchium\CoreDomain\Events;
6
7
8
abstract class AbstractDomainEvent implements DomainEventInterface
9
{
10
    /** @var  \DateTime */
11
    private $whenHappen;
12
13
    /** @var  array */
14
    private $payload;
15
16
    /**
17
     * AbstractDomainEvent constructor.
18
     *
19
     * @param \DateTime $whenHappen
20
     */
21
    public function __construct(\DateTime $whenHappen)
22
    {
23
        $this->whenHappen = $whenHappen;
24
        $this->payload = [];
25
    }
26
27
    /**
28
     * @return \DateTime
29
     */
30
    public function whenHappened()
31
    {
32
        return $this->whenHappen;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getPayload()
39
    {
40
        return $this->payload;
41
    }
42
43
    /**
44
     * @param string $name
45
     * @param $value
46
     */
47
    protected function setParam($name, $value)
48
    {
49
        $this->payload[$name] = $value;
50
    }
51
}
52