Completed
Push — 1.0 ( 7a7d48...309b8e )
by Nikita
06:17
created

Mygento_Metrika_Helper_Data   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 6
c 4
b 2
f 0
lcom 0
cbo 0
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addLog() 0 6 2
A getCode() 0 4 1
A setSessionData() 0 9 3
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_Helper_Data extends Mage_Core_Helper_Abstract
10
{
11
12
    public function addLog($text)
13
    {
14
        if (Mage::getStoreConfig('metrika/general/debug')) {
15
            Mage::log($text);
16
        }
17
    }
18
19
    public function getCode()
20
    {
21
        return Mage::getStoreConfig('metrika/metrika/counter');
22
    }
23
24
    /**
25
     * Set or Update Session Data
26
     *
27
     * @param $data
28
     * @return mixed
29
     */
30
    public function setSessionData($data)
31
    {
32
        $sessionData = Mage::getSingleton('core/session')->getMetrika();
33
        if ($sessionData && is_array($sessionData)) {
34
            $sessionData[] = $data;
35
            return Mage::getSingleton('core/session')->setMetrika($sessionData);
36
        }
37
        return Mage::getSingleton('core/session')->setMetrika(array($data));
38
    }
39
}
40