Passed
Push — master ( 62f043...679ba5 )
by devosc
03:11
created

Response::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 4.125

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 2
cts 4
cp 0.5
c 0
b 0
f 0
rs 9.6666
cc 3
eloc 5
nc 4
nop 1
crap 4.125
1
<?php
2
/**
3
 *
4
 */
5
6
namespace Mvc5\Http\Config;
7
8
use Mvc5\Arg;
9
use Mvc5\Http;
10
11
trait Response
12
{
13
    /**
14
     * @var array
15
     */
16 12
    protected $config = [];
17
18 12
    /**
19
     * @param array $config
20
     */
21
    function __construct($config = [])
22
    {
23
        !isset($config[Arg::HEADERS]) &&
24 11
            $config[Arg::HEADERS] = new Http\HttpHeaders;
25
26 11
        is_array($config[Arg::HEADERS]) &&
27
            $config[Arg::HEADERS] = new Http\HttpHeaders($config[Arg::HEADERS]);
28
29
        $this->config = $config;
30
    }
31
32 7
    /**
33
     * @return mixed
34 7
     */
35
    function body()
1 ignored issue
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
36
    {
37
        return $this[Arg::BODY];
38
    }
39
40 12
    /**
41
     * @return Http\Headers
42 12
     */
43
    function headers() : Http\Headers
1 ignored issue
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
    {
45
        return $this[Arg::HEADERS];
46
    }
47
48 9
    /**
49
     * @return string|null
50 9
     */
51
    function reason() : ?string
1 ignored issue
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
52
    {
53
        return $this[Arg::REASON];
54
    }
55
56
    /**
57
     * @return int|null
58
     */
59
    function status() : ?int
1 ignored issue
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
60
    {
61
        return $this[Arg::STATUS];
62
    }
63
64
    /**
65
     * @return string|null
66
     */
67
    function version() : ?string
1 ignored issue
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
68
    {
69
        return $this[Arg::VERSION];
70
    }
71
}
72