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.

ItemList::extract()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 28
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 8.439
c 0
b 0
f 0
cc 6
eloc 20
nc 6
nop 0
1
<?php
2
3
namespace Magium\Magento\Extractors\Customer\Order;
4
5
6
use Facebook\WebDriver\WebDriverElement;
7
use Magium\WebDriver\WebDriver;
8
9
class ItemList extends AbstractOrderExtractor
10
{
11
12
    const EXTRACTOR = 'Customer\Order\ItemList';
13
14
    protected $element;
15
    protected $items;
16
17
    /**
18
     * @return Item[]
19
     */
20
21
    public function getItems()
22
    {
23
        return $this->items;
24
    }
25
26
    public function extract()
27
    {
28
        if ($this->element instanceof WebDriverElement && $this->webDriver->elementAttached($this->element)) {
29
            return;
30
        }
31
        $this->element = $this->webDriver->byXpath('//body'); // Just need any element on the page
32
        $count = 0;
33
34
        $this->items = [];
35
36
        while ($this->webDriver->elementExists($this->theme->getOrderItemNameXpath(++$count), WebDriver::BY_XPATH)) {
37
            $productName = trim($this->webDriver->byXpath($this->theme->getOrderItemNameXpath($count))->getText());
38
            $productSku = trim($this->webDriver->byXpath($this->theme->getOrderItemSkuXpath($count))->getText());
39
            $productPrice = trim($this->webDriver->byXpath($this->theme->getOrderItemPriceXpath($count))->getText());
40
            $qty = trim($this->webDriver->byXpath($this->theme->getOrderItemQtyXpath($count))->getText());
41
            $qtyShipped = $qtyOrdered = 0;
42
            $matched = null;
43
            if (preg_match($this->theme->getOrderItemQtyOrderedRegex(), $qty, $matched)) {
44
                $qtyOrdered = $matched[1];
45
            }
46
            if (preg_match($this->theme->getOrderItemQtyShippedRegex(), $qty, $matched)) {
47
                $qtyShipped = $matched[1];
48
            }
49
            $orderSubtotal = trim($this->webDriver->byXpath($this->theme->getOrderItemSubtotalXpath($count))->getText());
50
            $item = new Item($productPrice, $productName, $qtyOrdered, $qtyShipped, $productSku, $orderSubtotal);
51
            $this->items[] = $item;
52
        }
53
    }
54
55
}