AbstractEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isPropagationStopped() 0 4 1
A stopPropagation() 0 4 1
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 9
    final public function isPropagationStopped(): bool
34
    {
35 9
        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 6
    final public function stopPropagation(): void
46
    {
47 6
        $this->propagationStopped = true;
48 6
    }
49
}
50