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

ByName::setName()   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 1
1
<?php
2
3
namespace Magium\Magento\Actions\Checkout\ShippingMethods;
4
5
use Magium\AbstractTestCase;
6
use Magium\Magento\AbstractMagentoTestCase;
7
use Magium\Magento\MissingInformationException;
8
use Magium\Magento\Themes\OnePageCheckout\AbstractThemeConfiguration;
9
use Magium\WebDriver\ExpectedCondition;
10
use Magium\WebDriver\WebDriver;
11
12
class ByName implements ShippingMethodInterface
13
{
14
    const ACTION = 'Checkout\ShippingMethods\ByName';
15
    protected $webDriver;
16
    protected $theme;
17
    protected $testCase;
18
19
    protected $name;
20
21
    public function __construct(
22
        WebDriver               $webDriver,
23
        AbstractThemeConfiguration  $themeConfiguration,
24
        AbstractMagentoTestCase $testCase
25
    ) {
26
        $this->webDriver        = $webDriver;
27
        $this->testCase         = $testCase;
28
        $this->theme            = $themeConfiguration;
29
    }
30
31
    public function setName($name)
32
    {
33
        $this->name = $name;
34
    }
35
36
    public function choose($required)
37
    {
38
        if (!$this->name) {
39
            throw new MissingInformationException('Missing the names');
40
        }
41
        $xpath = $this->theme->getShippingByNameXpath($this->name);
42
        try {
43
            $this->webDriver->wait()->until(
44
                ExpectedCondition::elementExists(
45
                    $xpath, AbstractTestCase::BY_XPATH
46
                )
47
            );
48
        } catch (\Exception $e) {
49
            throw new NoSuchShippingMethodException('Unable to find the shipping method: ' . $this->name);
50
        }
51
52
        // Some products, such as virtual products, do not get shipped
53
        if ($required) {
54
            $this->testCase->assertElementExists($xpath, AbstractTestCase::BY_XPATH);
55
            $this->testCase->assertElementDisplayed($xpath, AbstractTestCase::BY_XPATH);
56
        }
57
58
        if ($this->webDriver->elementDisplayed($xpath, AbstractTestCase::BY_XPATH)) {
59
            $this->webDriver->byXpath($xpath)->click();
60
        }
61
    }
62
63
}