Completed
Push — master ( 1972af...cf5cf8 )
by Rob
02:06
created

QueryStringValueWrapper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 32
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getQueryString() 0 4 2
A setLocalName() 0 4 1
A process() 0 12 3
1
<?php
2
3
namespace devtoolboxuk\cerberus\Wrappers;
4
5
class QueryStringValueWrapper extends Base
6
{
7
8
    private $queryArray = [];
9
10
    public function process()
11
    {
12
        $this->initWrapper($this->setLocalName());
13
14
        $this->getQueryString();
15
16
        list($key, $value) = array_pad(explode('|', $this->getReference()), 2, null);
17
18
        if (isset($this->queryArray[$key])) {
19
            if ($this->queryArray[$key] == $value) {
20
                $this->setScore($this->getRealScore());
21
                $this->setResult();
22
            }
23
        }
24
    }
25
26
    private function setLocalName()
27
    {
28
        $name = str_replace(__NAMESPACE__ . '\\', '', __CLASS__);
29
        return str_replace('Wrapper', '', $name);
30
    }
31
32
33
    private function getQueryString()
34
    {
35
        if (isset($_SERVER["QUERY_STRING"])) {
36
            parse_str($_SERVER["QUERY_STRING"], $this->queryArray);
37
        }
38
    }
39
40
}