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

Checkout::_isCheckoutMethod()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 2
eloc 5
nc 2
nop 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