BeforeRender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 0
c 1
b 1
f 0
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 3
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 bool $stopPropagation = false;
16
17
    /**
18
     * @param string $file The view file being rendered.
19
     * @param array $parameters The parameters array passed to the {@see View::render()} or {@see View::renderFile()}
20
     * method.
21
     */
22 17
    public function __construct(
23
        private View $view,
24
        private string $file,
25
        private array $parameters
26
    ) {
27 17
    }
28
29 1
    public function stopPropagation(): void
30
    {
31 1
        $this->stopPropagation = true;
32
    }
33
34 17
    public function isPropagationStopped(): bool
35
    {
36 17
        return $this->stopPropagation;
37
    }
38
39 1
    public function getView(): View
40
    {
41 1
        return $this->view;
42
    }
43
44 1
    public function getFile(): string
45
    {
46 1
        return $this->file;
47
    }
48
49 1
    public function getParameters(): array
50
    {
51 1
        return $this->parameters;
52
    }
53
}
54