AbstractScript   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 43
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 11 2
generateCode() 0 1 ?
A getGoogleAnalytics() 0 4 1
A setGoogleAnalytics() 0 4 1
1
<?php
2
3
namespace ByTIC\GoogleAnalytics\Tracking\Renderer\Script;
4
5
use ByTIC\GoogleAnalytics\Tracking\GoogleAnalytics;
6
7
/**
8
 * Class AbstractScript
9
 * @package ByTIC\GoogleAnalytics\Tracking
10
 */
11
abstract class AbstractScript
12
{
13
    /**
14
     * @var GoogleAnalytics
15
     */
16
    protected $googleAnalytics;
17
18
    /**
19
     * @return string
20
     */
21 1
    public function render()
22
    {
23
        // Do not render when tracker is disabled
24 1
        if (!$this->googleAnalytics->hasActiveTrackers()) {
25 1
            return '';
26
        }
27
28
        return '<script type="text/javascript">' . "\n"
29
            . $this->generateCode() . "\n"
30
            . '</script>';
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    abstract protected function generateCode();
37
38
    /**
39
     * @return GoogleAnalytics
40
     */
41
    public function getGoogleAnalytics()
42
    {
43
        return $this->googleAnalytics;
44
    }
45
46
    /**
47
     * @param GoogleAnalytics $googleAnalytics
48
     */
49 1
    public function setGoogleAnalytics($googleAnalytics)
50
    {
51 1
        $this->googleAnalytics = $googleAnalytics;
52 1
    }
53
}
54