AbstractEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stopPropagation() 0 3 1
A isPropagationStopped() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the Symfony EventDispatcher "Event" contract
11
 *  - (c) 2018-2019 Fabien Potencier
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace League\CommonMark\Event;
18
19
use Psr\EventDispatcher\StoppableEventInterface;
20
21
/**
22
 * Base class for classes containing event data.
23
 *
24
 * This class contains no event data. It is used by events that do not pass
25
 * state information to an event handler when an event is raised.
26
 *
27
 * You can call the method stopPropagation() to abort the execution of
28
 * further listeners in your event listener.
29
 */
30
abstract class AbstractEvent implements StoppableEventInterface
31
{
32
    /**
33
     * @var bool
34
     *
35
     * @psalm-readonly-allow-private-mutation
36
     */
37
    private $propagationStopped = false;
38
39
    /**
40
     * Returns whether further event listeners should be triggered.
41
     */
42 2997
    final public function isPropagationStopped(): bool
43
    {
44 2997
        return $this->propagationStopped;
45
    }
46
47
    /**
48
     * Stops the propagation of the event to further event listeners.
49
     *
50
     * If multiple event listeners are connected to the same event, no
51
     * further event listener will be triggered once any trigger calls
52
     * stopPropagation().
53
     */
54 6
    final public function stopPropagation(): void
55
    {
56 6
        $this->propagationStopped = true;
57 6
    }
58
}
59