Event::setParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace N1215\Tsukuyomi\Event;
5
6
class Event implements EventInterface
7
{
8
    /** @var string  */
9
    private $name;
10
11
    /** @var string|object|null */
12
    private $target;
13
14
    /** @var array  */
15
    private $params;
16
17
    /** @var bool  */
18
    private $isPropagationStopped;
19
20
    /**
21
     * @param string $name
22
     * @param string|object|null $target
23
     * @param array $params
24
     */
25 24
    public function __construct(string $name, $target = null, array $params = [])
26
    {
27 24
        $this->name = $name;
28 24
        $this->target = $target;
29 24
        $this->params = $params;
30 24
        $this->isPropagationStopped = false;
31 24
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 11
    public function getName(): string
37
    {
38 11
        return $this->name;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 3
    public function getTarget()
45
    {
46 3
        return $this->target;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52 3
    public function getParams(): array
53
    {
54 3
        return $this->params;
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60 3
    public function getParam(string $name)
61
    {
62 3
        if (!isset($this->params[$name])) {
63 1
            return null;
64
        }
65
66 3
        return $this->params[$name];
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72 1
    public function setName(string $name)
73
    {
74 1
        $this->name = $name;
75 1
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80 1
    public function setTarget($target)
81
    {
82 1
        $this->target = $target;
83 1
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88 1
    public function setParams(array $params)
89
    {
90 1
        $this->params = $params;
91 1
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96 2
    public function stopPropagation(bool $flag)
97
    {
98 2
        $this->isPropagationStopped = $flag;
99 2
    }
100
101
    /**
102
     * @inheritdoc
103
     */
104 8
    public function isPropagationStopped(): bool
105
    {
106 8
        return $this->isPropagationStopped;
107
    }
108
}
109