WaitForPageLoaded::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Magium\Actions;
4
5
use Facebook\WebDriver\WebDriverElement;
6
use Magium\Themes\ThemeConfigurationInterface;
7
use Magium\WebDriver\ExpectedCondition;
8
use Magium\WebDriver\WebDriver;
9
10
class WaitForPageLoaded implements StaticActionInterface
11
{
12
    const ACTION = 'WaitForPageLoaded';
13
14
    protected $webDriver;
15
    protected $theme;
16
17
    public function __construct(
18
        WebDriver $webDriver,
19
        ThemeConfigurationInterface $themeConfiguration
20
    )
21
    {
22
        $this->webDriver = $webDriver;
23
        $this->theme = $themeConfiguration;
24
    }
25
26
    public function execute(WebDriverElement $testElement = null)
27
    {
28
        if ($testElement instanceof WebDriverElement) {
29
            $this->webDriver->wait()->until(ExpectedCondition::elementRemoved($testElement));
0 ignored issues
show
Documentation introduced by
\Magium\WebDriver\Expect...ntRemoved($testElement) 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...
30
        }
31
32
        $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->theme->getGuaranteedPageLoadedElementDisplayedXpath(), 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...
33
        $element = $this->webDriver->byXpath($this->theme->getGuaranteedPageLoadedElementDisplayedXpath());
34
        $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...
35
    }
36
37
}
38