Completed
Push — master ( 1194b0...9342ad )
by Oss
03:45
created

HeaderList::initList()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 15
loc 15
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 10
nc 4
nop 0
crap 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A HeaderList::isSkipHeaderLine() 0 3 2
1
<?php
2
/**
3
 * @category    Brownie/HttpClient
4
 * @author      Brownie <[email protected]>
5
 * @license     http://www.gnu.org/copyleft/lesser.html
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
        );
56
    }
57
}
58