AbstractEvent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 33
ccs 6
cts 11
cp 0.5455
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A eventName() 0 3 1
A getName() 0 3 1
A stopPropagation() 0 5 1
A __construct() 0 2 1
A isPropagationStopped() 0 3 1
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