TitleEndsWith::assert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Magium\Assertions\Browser;
4
5
use Magium\AbstractTestCase;
6
use Magium\Assertions\AbstractAssertion;
7
use Magium\Assertions\SelectorAssertionInterface;
8
9
class TitleEndsWith extends AbstractAssertion implements SelectorAssertionInterface
10
{
11
    use TitleTrait;
12
13
    const ASSERTION = 'Browser\TitleEndsWith';
14
15
    public function assert()
16
    {
17
        $title = $this->webDriver->getTitle();
18
        AbstractTestCase::assertNotNull($title);
19
        AbstractTestCase::assertNotNull($this->title);
20
        $title = trim($title);
21
        $pos = strpos($title, $this->title);
22
        AbstractTestCase::assertNotFalse($pos);
0 ignored issues
show
Documentation introduced by
$pos is of type integer, but the function expects a boolean.

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...
23
        $testEquals = $pos + strlen($this->title);
24
        $browserEquals = strlen($title);
25
        AbstractTestCase::assertEquals($testEquals, $browserEquals);
26
    }
27
28
}
29