Passed
Pull Request — master (#1308)
by Frank
30:36
created

AbstractEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A eventName() 0 3 1
A getName() 0 3 1
A isPropagationStopped() 0 3 1
A stopPropagation() 0 5 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace League\OAuth2\Server\EventEmitting;
5
6
use League\Event\HasEventName;
7
use Psr\EventDispatcher\StoppableEventInterface;
8
9
class AbstractEvent implements  StoppableEventInterface, HasEventName
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    private $propagationStopped = false;
17
18
    public function __construct(string $name)
19
    {
20
        $this->name = $name;
21
    }
22
23
    public function eventName(): string
24
    {
25
        return $this->name;
26
    }
27
28
    /**
29
     * Backwards compatibility method
30
     *
31
     * @deprecated use eventName instead
32
     */
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    public function isPropagationStopped(): bool
39
    {
40
        return $this->propagationStopped;
41
    }
42
43
    public function stopPropagation(): self
44
    {
45
        $this->propagationStopped = true;
46
47
        return $this;
48
    }
49
}