Completed
Push — master ( 2c7ea9...284ef7 )
by Iman
01:59
created

DebugInfo::cacheState()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils;
4
5
6
class DebugInfo
7
{
8
    private $widget;
9
10
    function addIdentifierToHtml($widget)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
11
    {
12
        $this->widget = $widget;
13
        $this->addDebugInfo();
14
        $this->addHtmlComments();
15
    }
16
17
    private function addDebugInfo()
18
    {
19
        $this->widget->html = "<div title='" . class_basename($this->widget) . "::class || template : {$this->widget->template}" . $this->cacheState() . "' style='box-shadow: 0px 0px 15px 5px #00c62b inset'>" . $this->widget->html . "</div>";
20
    }
21
22
    private function addHtmlComments()
23
    {
24
        $this->widget->html = "<!-- '{$this->widget->friendlyName}' Widget Start -->" . $this->widget->html . "<!-- '{$this->widget->friendlyName}' Widget End -->";
25
    }
26
27
    /**
28
     * Generates a string of current cache configurations.
29
     * @return string
30
     */
31
    private function cacheState()
32
    {
33
        if ($this->widget->widgetShouldUseCache()) {
34
            return " || cache: {$this->widget->cacheLifeTime}(min)' ";
35
        }
36
        return " || cache : off";
37
    }
38
}