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

BeforeRender   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
eloc 13
c 1
b 1
f 0
dl 0
loc 46
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isPropagationStopped() 0 3 1
A getParameters() 0 3 1
A getView() 0 3 1
A getFile() 0 3 1
A stopPropagation() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\Event\WebView;
6
7
use Psr\EventDispatcher\StoppableEventInterface;
8
use Yiisoft\View\WebView;
9
10
/**
11
 * `BeforeRender` event is triggered by {@see WebView::renderFile()} right before it renders a view file.
12
 */
13
class BeforeRender implements StoppableEventInterface
14
{
15
    private WebView $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 WebView::render()} or {@see WebView::renderFile()} method.
24
     */
25
    private array $parameters;
26
27
    private bool $stopPropagation = false;
28
29 46
    public function __construct(WebView $view, string $file, array $parameters)
30
    {
31 46
        $this->view = $view;
32 46
        $this->file = $file;
33 46
        $this->parameters = $parameters;
34 46
    }
35
36 1
    public function stopPropagation(): void
37
    {
38 1
        $this->stopPropagation = true;
39 1
    }
40
41 46
    public function isPropagationStopped(): bool
42
    {
43 46
        return $this->stopPropagation;
44
    }
45
46 1
    public function getView(): WebView
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