Passed
Pull Request — master (#31)
by Daniel
02:18
created

Event::setRetries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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