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

View::endPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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