Completed
Push — master ( b5ed08...526d1c )
by Mārtiņš
8s
created

Common::getParameter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2.0625
1
<?php
2
3
namespace Fracture\Http\Headers;
4
5
abstract class Common implements Abstracted
6
{
7
8
    protected $headerName = 'Unspecified';
9
10
    protected $headerValue = '';
11
12
    protected $data = null;
13
14
15
    /**
16
     * @param string $headerValue
17
     */
18 52
    public function __construct($headerValue = '')
19
    {
20 52
        $this->headerValue = $headerValue;
21 52
    }
22
23
24
    /**
25
     * @param string $headerValue
26
     */
27 7
    public function setValue($headerValue)
28
    {
29 7
        $this->headerValue = $headerValue;
30 7
    }
31
32
33 4
    public function getName()
34
    {
35 4
        return $this->headerName;
36
    }
37
38 3
    public function getValue()
39
    {
40 3
        return $this->headerValue;
41
    }
42
43
44 41
    public function prepare()
45
    {
46 41
        $this->data = null;
47
48 41
        if (strlen($this->headerValue) > 0) {
49 36
            $this->data = $this->extractData($this->headerValue);
50 36
        }
51 41
    }
52
53
54
    abstract protected function extractData($headerValue);
55
56
57 21
    public function getParsedData()
58
    {
59 21
        return $this->data;
60
    }
61
62
63 1
    public function isFinal()
64
    {
65 1
        return false;
66
    }
67
68
69 1
    public function getParameter($name)
70
    {
71 1
        if (array_key_exists($name, $this->data)) {
72 1
            return $this->data[$name];
73
        }
74
75
        return null;
76
    }
77
}
78