Completed
Branch 2.0-dev (2c252e)
by Jan-Petter
02:43
created

CleanParamClient::check()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 9
nc 3
nop 1
1
<?php
2
namespace vipnytt\RobotsTxtParser\Client\Directives;
3
4
use vipnytt\RobotsTxtParser\Parser\Directives\DirectiveParserCommons;
5
6
/**
7
 * Class CleanParamClient
8
 *
9
 * @package vipnytt\RobotsTxtParser\Client\Directives
10
 */
11
class CleanParamClient
12
{
13
    use DirectiveParserCommons;
14
15
    /**
16
     * Clean-param
17
     * @var string[]
18
     */
19
    private $cleanParam = [];
20
21
    /**
22
     * CleanParamClient constructor.
23
     *
24
     * @param string[] $cleanParam
25
     */
26
    public function __construct(array $cleanParam)
27
    {
28
        $this->cleanParam = $cleanParam;
29
    }
30
31
    /**
32
     * Check
33
     *
34
     * @param  string $path
35
     * @return bool
36
     */
37
    public function check($path)
38
    {
39
        foreach ($this->cleanParam as $param => $paths) {
40
            if (
41
                (
42
                    mb_stripos($path, "?$param=") ||
43
                    mb_stripos($path, "&$param=")
44
                ) &&
45
                $this->checkPath($path, $paths)
0 ignored issues
show
Documentation introduced by
$paths is of type string, but the function expects a array<integer,string>.

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...
46
            ) {
47
                return true;
48
            }
49
        }
50
        return false;
51
    }
52
53
    /**
54
     * Export
55
     *
56
     * @return string[]
57
     */
58
    public function export()
59
    {
60
        return $this->cleanParam;
61
    }
62
}
63