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

OutputBuffering   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 10
c 1
b 1
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 3 1
A getClean() 0 13 2
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