IsUrl   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertSelector() 0 8 1
1
<?php
2
3
namespace Magium\Assertions\Url;
4
5
use Magium\AbstractTestCase;
6
7
class IsUrl extends AbstractUrlAssertion
8
{
9
10
    const ASSERTION = 'Url\IsUrl';
11
12
    public function assertSelector($selector)
13
    {
14
        $result = parse_url($selector);
15
        AbstractTestCase::assertInternalType('array', $result);
16
        AbstractTestCase::assertArrayHasKey('scheme', $result);
0 ignored issues
show
Security Bug introduced by
It seems like $result defined by parse_url($selector) on line 14 can also be of type false; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
17
        AbstractTestCase::assertArrayHasKey('host', $result);
0 ignored issues
show
Security Bug introduced by
It seems like $result defined by parse_url($selector) on line 14 can also be of type false; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
18
        AbstractTestCase::assertArrayHasKey('path', $result);
0 ignored issues
show
Security Bug introduced by
It seems like $result defined by parse_url($selector) on line 14 can also be of type false; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
19
    }
20
21
}
22