GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c6c0d3...e7409b )
by Kevin
06:55 queued 03:25
created

AbstractMagentoTestCase::getShippingMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Magium\Magento;
4
5
use Magium\AbstractTestCase;
6
use Magium\InvalidConfigurationException;
7
use Magium\Magento\Actions\Checkout\PaymentMethods\PaymentMethodInterface;
8
use Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface;
9
use Magium\Magento\Themes\AbstractThemeConfiguration;
10
use Magium\Util\TestCase\RegistrationListener;
11
12
abstract class AbstractMagentoTestCase extends AbstractTestCase
13
{
14
15
    protected function setUp()
16
    {
17
        self::addBaseNamespace('Magium\Magento');
18
        RegistrationListener::addCallback(new Registration(), 100);
19
        parent::setUp();
20
    }
21
22
    /**
23
     * @param $method
24
     * @return PaymentMethodInterface
25
     */
26
27 View Code Duplication
    public function setPaymentMethod($method)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
30
        // If we are passed just the class name we will prepend it with Magium\Magento\Actions\Checkout\PaymentMethods
31
        if (strpos($method, '\\') === false) {
32
            $method = 'Checkout\PaymentMethods\\' . $method;
33
            $method = self::resolveClass($method, 'Actions');
34
        }
35
        $reflection = new \ReflectionClass($method);
36
        if ($reflection->implementsInterface('Magium\Magento\Actions\Checkout\PaymentMethods\PaymentMethodInterface')) {
37
38
            $this->setTypePreference('Magium\Magento\Actions\Checkout\PaymentMethods\PaymentMethodInterface', $method);
39
        } else {
40
            throw new InvalidConfigurationException('The payment method must implement Magium\Magento\Actions\Checkout\PaymentMethods\PaymentMethodInterface');
41
        }
42
    }
43
44
    /**
45
     * @return PaymentMethodInterface
46
     */
47
48
    public function getPaymentMethod()
49
    {
50
        return $this->get('Magium\Magento\Actions\Checkout\PaymentMethods\PaymentMethodInterface');
51
    }
52
53
    /**
54
     * @return \Magium\Magento\Actions\Checkout\PaymentInformation
55
     */
56
57
    public function getPaymentInformation()
58
    {
59
        return $this->get('Magium\Magento\Actions\Checkout\PaymentInformation');
60
    }
61
62
    /**
63
     * This is more of a helper for code completion
64
     *
65
     * @param null $theme
66
     * @return AbstractThemeConfiguration
67
     */
68
69
    public function getTheme($theme = null)
70
    {
71
        return parent::getTheme($theme);
72
    }
73
74
    /**
75
     * @param $method
76
     * @return \Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface
77
     */
78
79 View Code Duplication
    public function setShippingMethod($method)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
    {
81
82
        // If we are passed just the class name we will prepend it with Magium\Magento\Actions\Checkout\PaymentMethods
83
        if (strpos($method, '\\') === false) {
84
            $method = 'Magium\Magento\Actions\Checkout\ShippingMethods\\' . $method;
85
        }
86
        $reflection = new \ReflectionClass($method);
87
        if ($reflection->implementsInterface('Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface')) {
88
            $this->setTypePreference('Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface', $method);
89
        } else {
90
            throw new InvalidConfigurationException('The payment method must implement Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface');
91
        }
92
    }
93
94
    /**
95
     * @return ShippingMethodInterface
96
     */
97
98
    public function getShippingMethod()
99
    {
100
        return $this->get('Magium\Magento\Actions\Checkout\ShippingMethods\ShippingMethodInterface');
101
    }
102
103
    public function switchThemeConfiguration($fullyQualifiedClassName)
104
    {
105
        $reflection = new \ReflectionClass($fullyQualifiedClassName);
106
        if ($reflection->isSubclassOf('Magium\Magento\Themes\NavigableThemeInterface')) {
107
            // Not entirely sure of hardcoding the various interface types.  May make this configurable
108
            parent::switchThemeConfiguration($fullyQualifiedClassName);
109
            $this->setTypePreference('Magium\Magento\Themes\AbstractThemeConfiguration',$fullyQualifiedClassName);
110
            $this->setTypePreference('Magium\Magento\Themes\NavigableThemeInterface',$fullyQualifiedClassName);
111
            $this->setTypePreference('Magium\Themes\BaseThemeInterface',$fullyQualifiedClassName);
112
113
            $this->setTypePreference('Magium\Magento\Themes\Customer\AbstractThemeConfiguration',$this->getTheme()->getCustomerThemeClass());
114
            $this->setTypePreference('Magium\Magento\Themes\OnePageCheckout\AbstractThemeConfiguration',$this->getTheme()->getCheckoutThemeClass());
115
        } else {
116
            throw new InvalidConfigurationException('The theme configuration extend Magium\Magento\Themes\NavigableThemeInterface');
117
        }
118
119
    }
120
121
}
122