PhpViewFileHelper   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 7 1
1
<?php
2
3
namespace Da\Mailer\Helper;
4
5
final class PhpViewFileHelper
6
{
7
    /**
8
     * Renders a view file as a PHP script.
9
     *
10
     * This method expects a php file and includes the file after it extracts the given parameters (name-value pairs)
11
     * to make them available to the php file. Captures the output and returns its result as a string.
12
     *
13
     * @param string $file full path of the view file
14
     * @param array $params the parameters that will be extracted and make them available to the php view file.
15
     *
16
     * @return string the rendering result.
17 2
     */
18
    public static function render($file, array $params = [])
19 2
    {
20 2
        ob_start();
21 2
        ob_implicit_flush(false);
22 2
        extract($params, EXTR_OVERWRITE);
23
        require $file;
24 2
        return ob_get_clean();
25
    }
26
}
27