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.

SystemConfiguration::navigateTo()   B
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 24
Code Lines 15

Duplication

Lines 6
Ratio 25 %

Importance

Changes 0
Metric Value
dl 6
loc 24
rs 8.6845
c 0
b 0
f 0
cc 4
eloc 15
nc 5
nop 1
1
<?php
2
3
namespace Magium\Magento\Navigators\Admin;
4
5
use Magium\AbstractTestCase;
6
use Magium\Actions\WaitForPageLoaded;
7
use Magium\InvalidInstructionException;
8
use Magium\Magento\AbstractMagentoTestCase;
9
use Magium\Magento\Themes\Admin\ThemeConfiguration;
10
use Magium\Navigators\ConfigurableNavigatorInterface;
11
use Magium\WebDriver\ExpectedCondition;
12
use Magium\WebDriver\WebDriver;
13
class SystemConfiguration implements ConfigurableNavigatorInterface
14
{
15
16
    const NAVIGATOR = 'Admin\SystemConfiguration';
17
    
18
    protected $webdriver;
19
    protected $themeConfiguration;
20
    protected $testCase;
21
    protected $loaded;
22
23
    public function __construct(
24
        ThemeConfiguration $theme,
25
        WebDriver $webdriver,
26
        AbstractMagentoTestCase $testCase,
27
        WaitForPageLoaded $loaded
28
    ) {
29
        $this->themeConfiguration   = $theme;
30
        $this->webdriver            = $webdriver;
31
        $this->testCase             = $testCase;
32
        $this->loaded               = $loaded;
33
    }
34
    
35
    public function navigateTo($path)
36
    {
37
        $instructions = explode('/', $path, 2);
38
        if (count($instructions) !== 2) {
39
            throw new InvalidInstructionException('System Configuration instructions need to be in the format of "Tab/Section"');
40
        }
41
        $tabXpath = $this->themeConfiguration->getSystemConfigTabsXpath($instructions[0]);
42
        $sectionDisplayXpath = $this->themeConfiguration->getSystemConfigSectionDisplayCheckXpath($instructions[1]);
43
        $sectionToggleXpath = $this->themeConfiguration->getSystemConfigSectionToggleXpath($instructions[1]);
44
45
        $this->testCase->assertElementExists($tabXpath, AbstractTestCase::BY_XPATH);
46 View Code Duplication
        if (!$this->webdriver->elementDisplayed($sectionDisplayXpath, WebDriver::BY_XPATH)) {
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...
47
48
            $this->webdriver->byXpath($tabXpath)->click();
49
50
            $this->webdriver->wait()->until(ExpectedCondition::elementExists($sectionDisplayXpath, AbstractTestCase::BY_XPATH));
0 ignored issues
show
Documentation introduced by
\Magium\WebDriver\Expect...ractTestCase::BY_XPATH) is of type object<Facebook\WebDrive...riverExpectedCondition>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
        }
52
53
        $this->testCase->assertElementExists($sectionToggleXpath, AbstractTestCase::BY_XPATH);
54
        if (!$this->webdriver->elementDisplayed($sectionDisplayXpath, AbstractTestCase::BY_XPATH)) {
55
            $element = $this->webdriver->byXpath($sectionToggleXpath);
56
            $element->click();
57
        }
58
    }
59
    
60
}
61