Completed
Push — develop ( 1f8c39...fd8d97 )
by Carlo
03:09
created

Checkout   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 66
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isGuestCheckout() 0 4 1
A isRegisterCheckout() 0 4 1
A isCustomerCheckout() 0 4 1
A quoteServiceSubmitAll() 0 7 1
A _isCheckoutMethod() 0 10 2
1
<?php
2
3
namespace Magefix\Fixture\Builder\Helper;
4
5
6
use Mage;
7
use Mage_Checkout_Model_Type_Onepage;
8
use Mage_Sales_Model_Quote;
9
10
class Checkout
11
{
12
    /**
13
     * @param array $checkoutMethodData
14
     *
15
     * @return bool
16
     *
17
     */
18
    public static function isGuestCheckout(array $checkoutMethodData)
19
    {
20
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST, $checkoutMethodData);
21
    }
22
23
    /**
24
     * @param array $checkoutMethodData
25
     *
26
     * @return bool
27
     *
28
     */
29
    public static function isRegisterCheckout(array $checkoutMethodData)
30
    {
31
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER, $checkoutMethodData);
32
    }
33
34
    /**
35
     * @param array $checkoutMethodData
36
     *
37
     * @return bool
38
     *
39
     */
40
    public static function isCustomerCheckout(array $checkoutMethodData)
41
    {
42
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER, $checkoutMethodData);
43
    }
44
45
    /**
46
     * @param Mage_Sales_Model_Quote $quote
47
     *
48
     * @return Mage_Sales_Model_Order
49
     *
50
     */
51
    public static function quoteServiceSubmitAll(Mage_Sales_Model_Quote $quote)
52
    {
53
        $service = Mage::getModel('sales/service_quote', $quote);
54
        $service->submitAll();
55
56
        return $service->getOrder();
57
    }
58
59
    /**
60
     * @param $method
61
     * @param $checkoutMethodData
62
     *
63
     * @return bool
64
     */
65
    private static function _isCheckoutMethod($method, $checkoutMethodData)
66
    {
67
        $isGuestCheckout = false;
68
69
        if ($checkoutMethodData['method'] == $method) {
70
            $isGuestCheckout = true;
71
        }
72
73
        return $isGuestCheckout;
74
    }
75
}
76