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 isPropagationStopped() 0 3 1
A getView() 0 3 1
A getParameters() 0 3 1
A getFile() 0 3 1
A __construct() 0 5 1
A stopPropagation() 0 3 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