Completed
Push — master ( de5c9f...2ef464 )
by Daniel
21s queued 11s
created

Event::getMetaProperties()   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 $name;
15
16
    /**
17
     * @var object
18
     */
19
    protected $payload;
20
21
    /**
22
     * @var string[]
23
     */
24
    protected $metaProperties;
25
26
    public function __construct()
27
    {
28
        $this->metaProperties = [];
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getName(): string
35
    {
36
        return $this->name;
37
    }
38
39
    /**
40
     * @param string $name
41
     *
42
     * @return \Jellyfish\Event\EventInterface
43
     */
44
    public function setName(string $name): EventInterface
45
    {
46
        $this->name = $name;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return object
53
     */
54
    public function getPayload(): object
55
    {
56
        return $this->payload;
57
    }
58
59
    /**
60
     * @param object $payload
61
     *
62
     * @return \Jellyfish\Event\EventInterface
63
     */
64
    public function setPayload(object $payload): EventInterface
65
    {
66
        $this->payload = $payload;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @return string[]
73
     */
74
    public function getMetaProperties(): array
75
    {
76
        return $this->metaProperties;
77
    }
78
79
    /**
80
     * @param string[] $metaProperties
81
     *
82
     * @return \Jellyfish\Event\EventInterface
83
     */
84
    public function setMetaProperties(array $metaProperties): EventInterface
85
    {
86
        $this->metaProperties = $metaProperties;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @param string $key
93
     *
94
     * @return string
95
     */
96
    public function getMetaProperty(string $key): ?string
97
    {
98
        if (!array_key_exists($key, $this->metaProperties)) {
99
            return null;
100
        }
101
        return $this->metaProperties[$key];
102
    }
103
104
    /**
105
     * @param string $key
106
     * @param string $metaProperty
107
     *
108
     * @return \Jellyfish\Event\EventInterface
109
     */
110
    public function setMetaProperty(string $key, string $metaProperty): EventInterface
111
    {
112
        $this->metaProperties[$key] = $metaProperty;
113
114
        return $this;
115
    }
116
}
117