Passed
Push — master ( 0074b5...431277 )
by Alexander
02:14
created

BeforeRun   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 23
ccs 5
cts 10
cp 0.5
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A stopPropagation() 0 3 1
A isPropagationStopped() 0 3 1
A getWidget() 0 3 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Yiisoft\Widget\Event;
5
6
use Psr\EventDispatcher\StoppableEventInterface;
7
use Yiisoft\Widget\Widget;
8
9
/**
10
 * BeforeRun event is raised right before executing a widget.
11
 */
12
class BeforeRun implements StoppableEventInterface
13
{
14
    private Widget $widget;
15
    private bool $stopPropagation = false;
16
17 3
    public function __construct(Widget $widget)
18
    {
19 3
        $this->widget = $widget;
20 3
    }
21
22
    public function stopPropagation(): void
23
    {
24
        $this->stopPropagation = true;
25
    }
26
27 3
    public function isPropagationStopped(): bool
28
    {
29 3
        return $this->stopPropagation;
30
    }
31
32
    public function getWidget(): Widget
33
    {
34
        return $this->widget;
35
    }
36
}
37