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

Event   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 10
eloc 18
c 1
b 0
f 1
dl 0
loc 106
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setMetaProperties() 0 5 1
A setName() 0 5 1
A getPayload() 0 3 1
A getMetaProperty() 0 6 2
A __construct() 0 3 1
A getMetaProperties() 0 3 1
A setPayload() 0 5 1
A setMetaProperty() 0 5 1
A getName() 0 3 1
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