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.

SwatchProcessor::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 3
eloc 15
nc 3
nop 2
1
<?php
2
3
namespace Magium\Magento\Extractors\Catalog\Product;
4
5
use Magium\Magento\Themes\AbstractThemeConfiguration;
6
use Magium\WebDriver\WebDriver;
7
8
class SwatchProcessor
9
{
10
11
    protected $webDriver;
12
    protected $theme;
13
14
    public function __construct(
15
        WebDriver $webDriver,
16
        AbstractThemeConfiguration $themeConfiguration
17
    )
18
    {
19
        $this->webDriver = $webDriver;
20
        $this->theme = $themeConfiguration;
21
    }
22
23
    public function isConfigurableSwatch($count)
24
    {
25
        return $this->webDriver->elementExists($this->theme->getConfigurableSwatchSelectorXpath($count, 1), WebDriver::BY_XPATH);
26
    }
27
28
    /**
29
     * @param $name
30
     * @param $count
31
     * @return Option
32
     */
33
34
    public function process($name, $count)
35
    {
36
        $swatch = new Option($name);
37
        $optionCount = 0;
38
        while ($this->webDriver->elementExists($this->theme->getConfigurableSwatchSelectorXpath($count, ++$optionCount), WebDriver::BY_XPATH)) {
39
40
            $itemOptionElement = $this->webDriver->byXpath($this->theme->getConfigurableSwatchSelectorXpath($count, $optionCount));
41
            $img = null;
42
            $available = !$this->webDriver->elementExists($this->theme->getConfigurableSwatchNotAvailableXpath($count, $optionCount), WebDriver::BY_XPATH);
43
            if ($this->webDriver->elementExists($this->theme->getConfigurableSwatchImgXpath($count, $optionCount), WebDriver::BY_XPATH)) {
44
                $img = $this->webDriver->byXpath($this->theme->getConfigurableSwatchImgXpath($count, $optionCount))->getAttribute('src');
45
            }
46
            $swatch->addValue(new SwatchValue(
47
                trim($itemOptionElement->getAttribute($this->theme->getConfigurableSwatchOptionLabelAttributeName())),
48
                $itemOptionElement,
49
                $available,
50
                $img
51
            ));
52
        }
53
        return $swatch;
54
    }
55
}