Passed
Push — master ( 4a5f5f...d4ccbb )
by Sebastian
03:14
created

OutputBuffering::getClean()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 7
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppLocalize\Editor;
6
7
class OutputBuffering
8
{
9
    const ERROR_RENDERING_FAILED = 91301;
10
11
    public static function start() : void
12
    {
13
        ob_start();
14
    }
15
16
    /**
17
     * @return string
18
     * @throws EditorException
19
     */
20
    public static function getClean() : string
21
    {
22
        $html = ob_get_clean();
23
24
        if($html !== false)
25
        {
26
            return $html;
27
        }
28
29
        throw new EditorException(
30
            'Rendering failed',
31
            'Output buffering returned false.',
32
            self::ERROR_RENDERING_FAILED
33
        );
34
    }
35
}
36