Event::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tebe\Pvc\Event;
6
7
class Event
8
{
9
10
    /**
11
     * @var string
12
     */
13
    private $name;
14
15
    /**
16
     * @var object
17
     */
18
    private $context;
19
20
    /**
21
     * @var array
22
     */
23
    private $info;
24
25
    /**
26
     * @var bool
27
     */
28
    private $cancelled = false;
29
30
    /**
31
     * Event constructor.
32
     * @param string $name
33
     * @param object|null $context
34
     * @param array|null $info
35
     */
36
    public function __construct(string $name, object $context = null, array $info = null)
37
    {
38
        $this->name = $name;
39
        $this->context = $context;
40
        $this->info = $info;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getName(): string
47
    {
48
        return $this->name;
49
    }
50
51
    /**
52
     * @return object|null
53
     */
54
    public function getContext()
55
    {
56
        return $this->context;
57
    }
58
59
    /**
60
     * @return bool
61
     */
62
    public function hasContext()
63
    {
64
        return $this->context !== null;
65
    }
66
67
    /**
68
     * @return array|null
69
     */
70
    public function getInfo()
71
    {
72
        return $this->info;
73
    }
74
75
    /**
76
     * @return bool
77
     */
78
    public function hasInfo()
79
    {
80
        return $this->info !== null;
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function isCancelled(): bool
87
    {
88
        return $this->cancelled;
89
    }
90
91
    /**
92
     * @return void
93
     */
94
    public function cancel(): void
95
    {
96
        $this->cancelled = true;
97
    }
98
}
99