setAdditionalLogData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
class Zenc_EmailLogger_Model_Observer
4
{
5
    private $_log;
6
7
    public function setAdditionalLogData(Varien_Event_Observer $observer)
8
    {
9
        $this->_log = $observer->getEvent()->getLog();
10
        $this->_setOrderData();
11
        $this->_setCustomerData();
12
        $this->_setQuoteData();
13
    }
14
15
    private function _getLog()
16
    {
17
        return $this->_log;
18
    }
19
20
    private function _setOrderData()
21
    {
22
        $session = Mage::getSingleton('checkout/session');
23
        if ($orderId = $session->getLastOrderId()) {
24
            $this->_getLog()->setOrderId($orderId);
25
        }
26
    }
27
28
    private function _setCustomerData()
29
    {
30
        $session = Mage::getSingleton('customer/session');
31
        if ($session->isLoggedIn()) {
32
            $this->_getLog()->setCustomerId($session->getCustomerId());
33
        }
34
    }
35
36
    private function _setQuoteData()
37
    {
38
        $session = Mage::getSingleton('checkout/session');
39
        if ($session->getQuoteId()) {
40
            $this->_getLog()->setQuoteId($session->getQuoteId());
41
        }
42
    }
43
}
44