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

Mygento_Metrika_Helper_Data::setSessionData()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 6
nc 2
nop 1
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