Completed
Pull Request — master (#5)
by Quim
04:42 queued 02:24
created

DomainEvent::setOccurredOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Domain\Event;
3
4
use Domain\Queue\Message;
5
6
class DomainEvent implements Message
7
{
8
    /**
9
     * @var string
10
     */
11
    protected $origin;
12
13
    /**
14
     * @var string
15
     */
16
    protected $name;
17
18
    /**
19
     * @var int
20
     */
21
    protected $occurredOn;
22
23
    /**
24
     * @var array
25
     */
26
    protected $body = array();
27
28
    /**
29
     * DomainEvent constructor.
30
     * @param $origin
31
     * @param $name
32
     * @param $occurredOn
33
     * @param array $body
34
     */
35
    public function __construct($origin, $name, $occurredOn, array $body = [])
36
    {
37
        $this->origin = $origin;
38
        $this->name = $name;
39
        $this->occurredOn = $occurredOn;
40
        $this->body = $body;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getOrigin()
47
    {
48
        return $this->origin;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName()
55
    {
56
        return $this->name;
57
    }
58
59
    /**
60
     * Timestamp
61
     *
62
     * @return int
63
     */
64
    public function getOccurredOn()
65
    {
66
        return $this->occurredOn;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getBody()
73
    {
74
        return $this->body;
75
    }
76
77
    /**
78
     * @return int
79
     */
80
    public function getDelay()
81
    {
82
        return 0;
83
    }
84
85
    /**
86
     * @param $origin
87
     * @return $this
88
     */
89
    public function setOrigin($origin)
90
    {
91
        $this->origin = $origin;
92
        return $this;
93
    }
94
95
    /**
96
     * @param $name
97
     * @return $this
98
     */
99
    public function setName($name)
100
    {
101
        $this->name = $name;
102
        return $this;
103
    }
104
105
    /**
106
     * Timestamp
107
     *
108
     * @param $occurredOn
109
     * @return $this
110
     */
111
    public function setOccurredOn($occurredOn)
112
    {
113
        $this->occurredOn = $occurredOn;
114
        return $this;
115
    }
116
117
    /**
118
     * @param array $body
119
     * @return $this
120
     */
121
    public function setBody(array $body)
122
    {
123
        $this->body = $body;
124
        return $this;
125
    }
126
127
    /**
128
     * @return array
129
     */
130
    public function jsonSerialize()
131
    {
132
        return [
133
            'origin' => $this->origin,
134
            'name' => $this->name,
135
            'occurredOn' => $this->occurredOn,
136
            'body' => $this->body
137
        ];
138
    }
139
}