Passed
Push — master ( 2af18a...ebd8c1 )
by Alexander
03:43
created

BeforeRender::stopPropagation()   A

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 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\Event\View;
6
7
use Psr\EventDispatcher\StoppableEventInterface;
8
use Yiisoft\View\View;
9
10
/**
11
 * `BeforeRender` event is triggered by {@see View::renderFile()} right before it renders a view file.
12
 */
13
final class BeforeRender implements StoppableEventInterface
14
{
15
    private View $view;
16
17
    /**
18
     * @var string The view file being rendered.
19
     */
20
    private string $file;
21
22
    /**
23
     * @var array The parameters array passed to the {@see View::render()} or {@see View::renderFile()} method.
24
     */
25
    private array $parameters;
26
27
    private bool $stopPropagation = false;
28
29 7
    public function __construct(View $view, string $file, array $parameters)
30
    {
31 7
        $this->view = $view;
32 7
        $this->file = $file;
33 7
        $this->parameters = $parameters;
34 7
    }
35
36 1
    public function stopPropagation(): void
37
    {
38 1
        $this->stopPropagation = true;
39 1
    }
40
41 7
    public function isPropagationStopped(): bool
42
    {
43 7
        return $this->stopPropagation;
44
    }
45
46 1
    public function getView(): View
47
    {
48 1
        return $this->view;
49
    }
50
51 1
    public function getFile(): string
52
    {
53 1
        return $this->file;
54
    }
55
56 1
    public function getParameters(): array
57
    {
58 1
        return $this->parameters;
59
    }
60
}
61