Passed
Push — master ( dbf047...1b561f )
by Daniel
02:26
created

Event::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\Event;
6
7
use function array_key_exists;
8
9
class Event implements EventInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $id;
15
16
    /**
17
     * @var string
18
     */
19
    protected $name;
20
21
    /**
22
     * @var object
23
     */
24
    protected $payload;
25
26
    /**
27
     * @var string[]
28
     */
29
    protected $metaProperties;
30
31
    /**
32
     * @param string $id
33
     */
34
    public function __construct(string $id)
35
    {
36
        $this->metaProperties = [];
37
        $this->id = $id;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getId(): string
44
    {
45
        return $this->id;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getName(): string
52
    {
53
        return $this->name;
54
    }
55
56
    /**
57
     * @param string $name
58
     *
59
     * @return \Jellyfish\Event\EventInterface
60
     */
61
    public function setName(string $name): EventInterface
62
    {
63
        $this->name = $name;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return object
70
     */
71
    public function getPayload(): object
72
    {
73
        return $this->payload;
74
    }
75
76
    /**
77
     * @param object $payload
78
     *
79
     * @return \Jellyfish\Event\EventInterface
80
     */
81
    public function setPayload(object $payload): EventInterface
82
    {
83
        $this->payload = $payload;
84
85
        return $this;
86
    }
87
88
    /**
89
     * @return string[]
90
     */
91
    public function getMetaProperties(): array
92
    {
93
        return $this->metaProperties;
94
    }
95
96
    /**
97
     * @param string[] $metaProperties
98
     *
99
     * @return \Jellyfish\Event\EventInterface
100
     */
101
    public function setMetaProperties(array $metaProperties): EventInterface
102
    {
103
        $this->metaProperties = $metaProperties;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @param string $key
110
     *
111
     * @return string
112
     */
113
    public function getMetaProperty(string $key): ?string
114
    {
115
        if (!array_key_exists($key, $this->metaProperties)) {
116
            return null;
117
        }
118
        return $this->metaProperties[$key];
119
    }
120
121
    /**
122
     * @param string $key
123
     * @param string $metaProperty
124
     *
125
     * @return \Jellyfish\Event\EventInterface
126
     */
127
    public function setMetaProperty(string $key, string $metaProperty): EventInterface
128
    {
129
        $this->metaProperties[$key] = $metaProperty;
130
131
        return $this;
132
    }
133
}
134