Passed
Pull Request — master (#143)
by Alexander
02:07
created

View   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 1
f 0
dl 0
loc 20
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A beginPage() 0 6 2
A endPage() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View;
6
7
use Yiisoft\View\Event\PageBegin;
8
use Yiisoft\View\Event\PageEnd;
9
10
/**
11
 * View represents a view object in the MVC pattern.
12
 *
13
 * View provides a set of methods (e.g. {@see View::render()}) for rendering purpose.
14
 *
15
 * For more details and usage information on View, see the [guide article on views](guide:structure-views).
16
 */
17
final class View extends BaseView
18
{
19
    /**
20
     * Marks the beginning of a page.
21
     */
22
    public function beginPage(): void
23
    {
24
        ob_start();
25
        PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
26
27
        $this->eventDispatcher->dispatch(new PageBegin($this->getViewFile()));
28
    }
29
30
    /**
31
     * Marks the ending of a page.
32
     */
33
    public function endPage(): void
34
    {
35
        $this->eventDispatcher->dispatch(new PageEnd($this->getViewFile()));
36
        ob_end_flush();
37
    }
38
}
39