Completed
Push — master ( 4a8c36...355a61 )
by Hong
02:15
created

StoppableEvent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isPropagationStopped() 0 4 1
A stopEvent() 0 4 1
1
<?php
2
3
/**
4
 * Phoole (PHP7.2+)
5
 *
6
 * @category  Library
7
 * @package   Phoole\Event
8
 * @copyright Copyright (c) 2019 Hong Zhang
9
 */
10
declare(strict_types=1);
11
12
namespace Phoole\Event\Events;
13
14
use Psr\EventDispatcher\StoppableEventInterface;
15
16
/**
17
 * StoppableEvent prototype
18
 *
19
 * @package Phoole\Event
20
 */
21
abstract class StoppableEvent implements StoppableEventInterface
22
{
23
    /**
24
     * @var    bool
25
     */
26
    protected $stopped = FALSE;
27
28
    /**
29
     * Is propagation stopped?
30
     *
31
     * This will typically only be used by the Dispatcher to determine if the
32
     * previous listener halted propagation.
33
     *
34
     * @return bool
35
     *   True if the Event is complete and no further listeners should be called.
36
     *   False to continue calling listeners.
37
     */
38
    public function isPropagationStopped(): bool
39
    {
40
        return $this->stopped;
41
    }
42
43
    /**
44
     * @return void
45
     */
46
    public function stopEvent(): void
47
    {
48
        $this->stopped = TRUE;
49
    }
50
}