Main::hookTemplateRender()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 2
nop 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