Header   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toString() 0 8 3
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\Util\StorageArray;
11
12
/**
13
 * HTTP Header class.
14
 *
15
 * @method  Header      setName(string $name)       Sets the name of the header.
16
 * @method  string      getName()                   Returns header name.
17
 * @method  Header      setValue(string $value)     Sets the value of the header.
18
 * @method  string      getValue()                  Returns header value.
19
 */
20
class Header extends StorageArray
21
{
22
23
    /**
24
     * List of supported fields.
25
     *
26
     * @var array
27
     */
28
    protected $fields = array(
29
        'name' => null,     // Header name.
30
        'value' => null,    // Header value.
31
    );
32
33
    /**
34
     * Get the value as a string.
35
     *
36
     * @return null|string
37
     */
38 4
    public function toString()
39
    {
40 4
        $name = $this->getName();
41 4
        $value = $this->getValue();
42 4
        if (!empty($name) && !empty($value)) {
43 1
            return $name . ': ' . $value;
44
        }
45 3
        return null;
46
    }
47
}
48