AbstractEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\OAuth2\Server\EventEmitting;
6
7
use League\Event\HasEventName;
8
use Psr\EventDispatcher\StoppableEventInterface;
9
10
class AbstractEvent implements StoppableEventInterface, HasEventName
11
{
12
    private bool $propagationStopped = false;
13
14 40
    public function __construct(private string $name)
15
    {
16 40
    }
17
18 40
    public function eventName(): string
19
    {
20 40
        return $this->name;
21
    }
22
23
    /**
24
     * Backwards compatibility method
25
     *
26
     * @deprecated use eventName instead
27
     */
28
    public function getName(): string
29
    {
30
        return $this->name;
31
    }
32
33 5
    public function isPropagationStopped(): bool
34
    {
35 5
        return $this->propagationStopped;
36
    }
37
38
    public function stopPropagation(): self
39
    {
40
        $this->propagationStopped = true;
41
42
        return $this;
43
    }
44
}
45