Completed
Push — master ( 0f12ee...dd1eab )
by recca
02:21
created

Template::minify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0046

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
crap 1.0046
rs 9.4285
1
<?php
2
3
namespace Recca0120\LaravelTracy;
4
5
class Template
6
{
7
    protected $attributes = [];
8
9
    /**
10
     * setAttributes.
11
     *
12
     * @param array $attributes
13
     */
14 1
    public function setAttributes($attributes)
15
    {
16 1
        $this->attributes = $attributes;
17 1
    }
18
19
    /**
20
     * render.
21
     *
22
     * @param string $view
23
     * @return string
24
     */
25 1
    public function render($view)
26
    {
27 1
        extract($this->attributes);
28
29 1
        ob_start();
30 1
        require $view;
31
32 1
        return $this->minify(ob_get_clean());
33
    }
34
35
    /**
36
     * minify.
37
     *
38
     * @param string $html
39
     * @return string
40
     */
41 1
    protected function minify($html)
0 ignored issues
show
Unused Code introduced by
The parameter $html is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43 1
        return preg_replace(
44 1
            ['/<!--(.*)-->/Uis', "/[[:blank:]]+/"],
45 1
            ['', ' '],
46 1
            str_replace(["\n","\r","\t"],'',$buf)
0 ignored issues
show
Bug introduced by
The variable $buf does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
47
        );
48
    }
49
}
50