AbstractEvent::isPropagationStopped()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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
    /** @psalm-readonly-allow-private-mutation */
33
    private bool $propagationStopped = false;
34
35
    /**
36
     * Returns whether further event listeners should be triggered.
37
     */
38 2318
    final public function isPropagationStopped(): bool
39
    {
40 2318
        return $this->propagationStopped;
41
    }
42
43
    /**
44
     * Stops the propagation of the event to further event listeners.
45
     *
46
     * If multiple event listeners are connected to the same event, no
47
     * further event listener will be triggered once any trigger calls
48
     * stopPropagation().
49
     */
50 4
    final public function stopPropagation(): void
51
    {
52 4
        $this->propagationStopped = true;
53
    }
54
}
55