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.

Customer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 27.69 %

Coupling/Cohesion

Components 1
Dependencies 11

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 11
dl 18
loc 65
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 18 18 1
B navigateTo() 0 31 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Magium\Magento\Navigators\Admin;
4
5
use Magium\Magento\AbstractMagentoTestCase;
6
use Magium\Magento\Actions\Admin\Tables\ClearTableFilters;
7
use Magium\Magento\Actions\Admin\Tables\ClickButton;
8
use Magium\Magento\Actions\Admin\WaitForLoadingMask;
9
use Magium\Magento\Navigators\Admin\Customer\AbstractCustomerNavigation;
10
use Magium\Magento\Themes\Admin\ThemeConfiguration;
11
use Magium\Navigators\NavigatorInterface;
12
use Magium\WebDriver\ExpectedCondition;
13
use Magium\WebDriver\WebDriver;
14
15
class Customer implements NavigatorInterface
16
{
17
    const NAVIGATOR = 'Admin\Customer';
18
19
    protected $webDriver;
20
    protected $themeConfiguration;
21
    protected $adminLogin;
22
    protected $adminMenuNavigator;
23
    protected $clearTableFilters;
24
    protected $clickButton;
25
    protected $waitForLoadingMask;
26
    protected $testCase;
27
28 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
29
        WebDriver                   $webDriver,
30
        ThemeConfiguration     $themeConfiguration,
31
        AdminMenu          $adminMenuNavigator,
32
        ClearTableFilters           $clearTableFilters,
33
        ClickButton                 $clickButton,
34
        WaitForLoadingMask          $waitForLoadingMask,
35
        AbstractMagentoTestCase     $testCase
36
    )
37
    {
38
        $this->webDriver                = $webDriver;
39
        $this->themeConfiguration       = $themeConfiguration;
40
        $this->adminMenuNavigator       = $adminMenuNavigator;
41
        $this->clearTableFilters        = $clearTableFilters;
42
        $this->clickButton              = $clickButton;
43
        $this->waitForLoadingMask       = $waitForLoadingMask;
44
        $this->testCase                 = $testCase;
45
    }
46
47
    public function navigateTo(AbstractCustomerNavigation $navigation)
48
    {
49
50
        $this->adminMenuNavigator->navigateTo('Customers/Manage Customers');
51
52
        $this->clearTableFilters->clear();
53
54
        $parts = explode('-', $navigation->getSelectorID());
55
        foreach ($parts as $part) {
56
            $element = $this->webDriver->byId($part);
57
            $element->sendKeys($navigation->getSearch());
58
        }
59
60
        $this->clickButton->click($this->themeConfiguration->getSearchButtonText());
61
        $this->testCase->sleep('100ms');
62
        $this->waitForLoadingMask->wait();
63
64
        $selectXpath = $this->themeConfiguration->getSelectCustomerXpath($navigation->getSearch());
65
66
        $this->testCase->assertElementDisplayed($selectXpath, WebDriver::BY_XPATH);
67
        $element = $this->webDriver->byXpath($selectXpath);
68
69
        $element->click();
70
        $elementExists = $this->testCase->getTranslator()->translatePlaceholders('//h4[.="{{Personal Information}}"]');
71
        $this->webDriver->wait()->until(ExpectedCondition::elementExists($elementExists, WebDriver::BY_XPATH));
0 ignored issues
show
Documentation introduced by
\Magium\WebDriver\Expect...er\WebDriver::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...
72
73
        $element = $this->webDriver->byXpath($elementExists);
74
75
        $this->webDriver->wait()->until(ExpectedCondition::visibilityOf($element));
0 ignored issues
show
Documentation introduced by
\Magium\WebDriver\Expect...:visibilityOf($element) is of type object<Magium\WebDriver\ExpectedCondition>, 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...
76
77
    }
78
79
}