HeaderList   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createCollectionItem() 0 3 1
A isSkipHeaderLine() 0 3 2
A getParams() 0 6 1
1
<?php
2
/**
3
 * @category    Brownie/HttpClient
4
 * @author      Brownie <[email protected]>
5
 * @license     https://opensource.org/licenses/MIT
6
 */
7
8
namespace Brownie\HttpClient\Header;
9
10
use Brownie\HttpClient\HeadList;
11
12
/**
13
 * HTTP headers collection.
14
 */
15
class HeaderList extends HeadList
16
{
17
18
    /**
19
     * Returns the HTTP header skip flag.
20
     *
21
     * @param string    $headerLine     HTTP header line.
22
     *
23
     * @return bool
24
     */
25 3
    protected function isSkipHeaderLine($headerLine)
26
    {
27 3
        return ($this->isHeaderHTTP($headerLine) || $this->isHeaderSetCookie($headerLine));
28
    }
29
30
    /**
31
     * Creates a data model for the collection.
32
     *
33
     * @param string    $headerLine     HTTP header line.
34
     *
35
     * @return Header
36
     */
37 3
    public function createCollectionItem($headerLine)
38
    {
39 3
        return new Header($this->getParams($headerLine));
40
    }
41
42
    /**
43
     * Returns HTTP header parameters.
44
     *
45
     * @param string    $headerLine     HTTP header line.
46
     *
47
     * @return array
48
     */
49 3
    private function getParams($headerLine)
50
    {
51 3
        $pairParam = explode(':', trim($headerLine), 2);
52
        return array(
53 3
            'name' => trim($pairParam[0]),
54 3
            'value' => trim($pairParam[1])
55 3
        );
56
    }
57
}
58