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.

AddTrackingNumber::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

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.4285
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace Magium\Magento\Actions\Admin\Orders\Ship;
4
5
use Facebook\WebDriver\WebDriverSelect;
6
use Magium\AbstractTestCase;
7
use Magium\Actions\StaticActionInterface;
8
use Magium\Actions\SubAction\SubActionInterface;
9
use Magium\Magento\Themes\Admin\ThemeConfiguration;
10
use Magium\WebDriver\WebDriver;
11
12
class AddTrackingNumber implements SubActionInterface, StaticActionInterface 
13
{
14
15
    const ACTION = 'Admin\Orders\Ship\AddTrackingNumber';
16
17
    const CARRIER_CUSTOM    = 'custom';
18
    const CARRIER_DHL       = 'dhl';
19
    const CARRIER_FEDEX     = 'fedex';
20
    const CARRIER_UPS       = 'ups';
21
    const CARRIER_USPS      = 'usps';
22
    const CARRIER_DHLINT    = 'dhlint';
23
24
    protected $carrier;
25
    protected $title;
26
    protected $number;
27
28
    protected $theme;
29
    protected $webDriver;
30
    protected $testCase;
31
32
    public function __construct(
33
        WebDriver $webDriver,
34
        ThemeConfiguration $themeConfiguration,
35
        AbstractTestCase $testCase
36
    )
37
    {
38
        $this->theme = $themeConfiguration;
39
        $this->webDriver = $webDriver;
40
        $this->testCase = $testCase;
41
    }
42
43
    /**
44
     * @param mixed $carrier
45
     */
46
    public function setCarrier($carrier)
47
    {
48
        $this->carrier = $carrier;
49
    }
50
51
    /**
52
     * @param mixed $number
53
     */
54
    public function setNumber($number)
55
    {
56
        $this->number = $number;
57
    }
58
59
    /**
60
     * @param mixed $title
61
     */
62
    public function setTitle($title)
63
    {
64
        $this->title = $title;
65
    }
66
67
    public function execute()
68
    {
69
        $this->testCase->byText('{{Add Tracking Number}}')->click();
70
        $this->testCase->sleep('1s'); // Give the UI time to update
71
        $count = 0;
72
        do {
73
            $count++;
74
        } while ($this->webDriver->elementExists($this->theme->getShippingCarrierXpath($count), WebDriver::BY_XPATH));
75
        $count--; // $count was the last one that DOESN'T exist.  Go back one.
76
77
        if ($this->carrier) {
78
            $select = new WebDriverSelect($this->webDriver->byXpath($this->theme->getShippingCarrierXpath($count)));
79
            if (strpos($this->carrier, 'label=') === 0) {
80
                $carrier = substr($this->carrier, strlen('label='));
81
                $select->selectByVisibleText($carrier);
82
            } else {
83
                $select->selectByValue($this->carrier);
84
            }
85
        }
86
87
        if ($this->title) {
88
            $element = $this->webDriver->byXpath($this->theme->getShippingTitleXpath($count));
89
            $element->clear();
90
            $element->sendKeys($this->title);
91
        }
92
93
        if ($this->number) {
94
            $element = $this->webDriver->byXpath($this->theme->getShippingTrackingNumberXpath($count));
95
            $element->clear();
96
            $element->sendKeys($this->number);
97
        }
98
    }
99
100
}