Mygento_Metrika_Block_Tracker   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 8
Bugs 2 Features 1
Metric Value
wmc 12
c 8
b 2
f 1
lcom 0
cbo 0
dl 0
loc 61
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCode() 0 4 1
A getDynamicTrackers() 0 9 3
B getOptions() 0 22 6
A _toHtml() 0 7 2
1
<?php
2
3
/**
4
 *
5
 * @category   Mygento
6
 * @package    Mygento_Metrika
7
 * @copyright  Copyright © 2015 NKS LLC. (http://www.mygento.ru)
8
 */
9
class Mygento_Metrika_Block_Tracker extends Mage_Core_Block_Template
10
{
11
12
    /**
13
     * Get Tracking code ID
14
     * @return string
15
     */
16
    public function getCode()
17
    {
18
        return Mage::helper('metrika')->getCode();
19
    }
20
21
    /**
22
     * Get Dynamic tracker through events
23
     * @return array
24
     */
25
    public function getDynamicTrackers()
26
    {
27
        $data = Mage::getSingleton('core/session')->getMetrika();
28
        if ($data && is_array($data)) {
29
            Mage::getSingleton('core/session')->unsMetrika();
30
            return $data;
31
        }
32
        return array();
33
    }
34
35
    /**
36
     *  Get parameters for counter
37
     *  @return array
38
     */
39
    public function getOptions()
40
    {
41
        $options = array();
42
        $options['id'] = $this->getCode();
43
        if (Mage::getStoreConfig('metrika/metrika/webvisor')) {
44
            $options['webvisor'] = (bool) Mage::getStoreConfig('metrika/metrika/webvisor');
45
        }
46
        if (Mage::getStoreConfig('metrika/metrika/clickmap')) {
47
            $options['clickmap'] = (bool) Mage::getStoreConfig('metrika/metrika/clickmap');
48
        }
49
        if (Mage::getStoreConfig('metrika/metrika/tracklinks')) {
50
            $options['trackLinks'] = (bool) Mage::getStoreConfig('metrika/metrika/tracklinks');
51
        }
52
        if (Mage::getStoreConfig('metrika/metrika/accuratetrackbounce')) {
53
            $options['accurateTrackBounce'] = (bool) Mage::getStoreConfig('metrika/metrika/accuratetrackbounce');
54
        }
55
        if (Mage::getStoreConfig('metrika/metrika/ecommerce')) {
56
            $options['ecommerce'] = (bool) Mage::getStoreConfig('metrika/metrika/ecommerce');
57
        }
58
59
        return $options;
60
    }
61
62
    protected function _toHtml()
63
    {
64
        if (!Mage::getStoreConfig('metrika/general/enabled')) {
65
            return '';
66
        }
67
        return parent::_toHtml();
68
    }
69
}
70