| Total Complexity | 8 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Coverage | 92% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class DebugInfo |
||
| 9 | { |
||
| 10 | private $widget; |
||
| 11 | |||
| 12 | private $html; |
||
| 13 | |||
| 14 | private $policies; |
||
| 15 | |||
| 16 | 6 | public function __construct() |
|
| 17 | { |
||
| 18 | 6 | $this->policies = app(Policies::class); |
|
| 19 | 6 | } |
|
| 20 | |||
| 21 | /** |
||
| 22 | * @param object $widget |
||
| 23 | * @param string $html |
||
| 24 | * @return string |
||
| 25 | */ |
||
| 26 | 6 | public function addIdentifierToHtml($widget, string $html): string |
|
| 27 | { |
||
| 28 | 6 | $this->widget = $widget; |
|
| 29 | 6 | $this->html = $html; |
|
| 30 | 6 | $this->addDebugInfo(); |
|
| 31 | 6 | $this->addHtmlComments(); |
|
| 32 | |||
| 33 | 6 | return $this->html; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Adds debug info to html as HTML title tags. |
||
| 38 | */ |
||
| 39 | 6 | private function addDebugInfo(): void |
|
| 44 | 6 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Generates a string of current cache configurations. |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | 6 | private function cacheState(): string |
|
| 52 | { |
||
| 53 | 6 | if (! $this->policies->widgetShouldUseCache()) { |
|
| 54 | 6 | return ' 
 Cache: is globally turned off (You should put "enable_cache" => true in config\widgetize.php) '; |
|
| 55 | } |
||
| 56 | $l = $this->widget->cacheLifeTime->i ?? 0; |
||
| 57 | |||
| 58 | return " 
Cache : {$l} (min) "; |
||
| 59 | } |
||
| 60 | |||
| 61 | 6 | private function addHtmlComments(): void |
|
| 64 | 6 | } |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @param string $tpl |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | 6 | private function getTplPath(string $tpl): string |
|
| 77 | } |
||
| 78 | } |
||
| 79 |