Completed
Push — master ( 72e87e...d3fffa )
by Colin
17s queued 11s
created

AbstractEvent::isPropagationStopped()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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