Completed
Push — master ( 8f1053...c250e4 )
by Antonio
13:19
created

PhpViewFileHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 23
rs 10

1 Method

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