Completed
Pull Request — master (#2)
by Jan-Petter
02:43
created

CleanParamClient::isListed()   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 implements ClientInterface
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 $url
35
     * @return bool
36
     */
37
    public function isListed($url)
38
    {
39
        foreach ($this->cleanParam as $param => $paths) {
40
            if (
41
                (
42
                    mb_stripos($url, "?$param=") ||
43
                    mb_stripos($url, "&$param=")
44
                ) &&
45
                $this->checkPaths($url, $paths)
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