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.

AddToCart::getElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Magium\Magento\Extractors\Catalog\Cart;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Facebook\WebDriver\WebDriverElement;
7
use Magium\Extractors\AbstractExtractor;
8
use Magium\Magento\Actions\Cart\NoSuchElementException;
9
use Magium\Magento\Themes\AbstractThemeConfiguration;
10
11
class AddToCart extends AbstractExtractor
12
{
13
14
    /**
15
     * @var AbstractThemeConfiguration
16
     */
17
18
    protected $theme;
19
20
    protected $element;
21
22
    /**
23
     * @return WebDriverElement
24
     */
25
26
    public function getElement()
27
    {
28
        $this->extract();
29
        return $this->element;
30
    }
31
32
    public function extract()
33
    {
34 View Code Duplication
        if (!$this->webDriver->elementExists($this->theme->getAddToCartXpath(), 'byXpath')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
35
            throw new NoSuchElementException('Could not find the simple add to cart element with the Xpath: ' . $this->theme->getAddToCartXpath());
36
        };
37
38
        $elements = $this->webDriver->findElements(WebDriverBy::xpath($this->theme->getAddToCartXpath()));
39
        foreach ($elements as $element) {
40
            if ($element->isDisplayed()) {
41
                $this->element = $element;
42
                return;
43
            }
44
        }
45
46
47
    }
48
49
}