Main   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A hookTemplateRender() 0 15 4
1
<?php
2
3
/**
4
 * @package Google Analytics Charts
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2018, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0
8
 */
9
10
namespace gplcart\modules\ga_chart;
11
12
/**
13
 * Main class for Google Analytics Charts module
14
 */
15
class Main
16
{
17
    /**
18
     * Implements "template.render"
19
     * @param array $templates
20
     * @param array $data
21
     * @param string| null $rendered
22
     * @param \gplcart\core\Controller $controller
23
     */
24
    public function hookTemplateRender($templates, $data, $rendered, $controller)
0 ignored issues
show
Unused Code introduced by
The parameter $rendered 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...
25
    {
26
        $template = reset($templates);
27
28
        if (strpos($template, '/modules/ga_report/templates/panels/') !== false
29
            && isset($data['content']['data']['report']['data'])
30
            && isset($data['content']['data']['handler']['id'])) {
31
32
            $handler_id = $data['content']['data']['handler']['id'];
33
            $controller->setJsSettings("ga_chart_$handler_id", $data['content']['data']['report']['data']);
34
35
            $controller->setJs(__DIR__ . "/js/handlers/$handler_id.js");
36
            $controller->setJs(__DIR__ . "/js/common.js");
37
        }
38
    }
39
}
40