Completed
Push — master ( a6fe0f...b0c0c1 )
by Sebastian
02:05
created

ErrorResult::fromPrimitives()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
namespace DjThossi\SmokeTestingPhp\Result;
3
4
use DjThossi\SmokeTestingPhp\Collection\HeaderCollection;
5
use DjThossi\SmokeTestingPhp\ValueObject\ErrorMessage;
6
use DjThossi\SmokeTestingPhp\ValueObject\Url;
7
8
class ErrorResult implements Result
9
{
10
    /**
11
     * @var Url
12
     */
13
    private $url;
14
15
    /**
16
     * @var HeaderCollection
17
     */
18
    private $headers;
19
20
    /**
21
     * @var ErrorMessage
22
     */
23
    private $errorMessage;
24
25
    /**
26
     * @param Url $url
27
     * @param HeaderCollection $headers
28
     * @param ErrorMessage $errorMessage
29
     */
30
    public function __construct(Url $url, HeaderCollection $headers, ErrorMessage $errorMessage)
31
    {
32
        $this->url = $url;
33
        $this->headers = $headers;
34
        $this->errorMessage = $errorMessage;
35
    }
36
37
    /**
38
     * @param string $url
39
     * @param array $headerData
40
     * @param $errorMessage
41
     *
42
     * @return ErrorResult
43
     */
44
    public static function fromPrimitives(
45
        $url,
46
        array $headerData,
47
        $errorMessage
48
    ) {
49
        return new self(
50
            new Url($url),
51
            HeaderCollection::fromArray($headerData),
52
            new ErrorMessage($errorMessage)
53
        );
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function asString()
60
    {
61
        return $this->errorMessage->asString();
62
    }
63
64
    /**
65
     * @return HeaderCollection
66
     */
67
    public function getHeaders()
68
    {
69
        return $this->headers;
70
    }
71
72
    /**
73
     * @return Url
74
     */
75
    public function getUrl()
76
    {
77
        return $this->url;
78
    }
79
80
    /**
81
     * @return bool
82
     */
83
    public function isValidResult()
84
    {
85
        return false;
86
    }
87
88
    public function getTimeToFirstByte()
89
    {
90
        throw new NotImplementedException('getTimeToFirstByte is not implemented');
91
    }
92
93
    public function getBody()
94
    {
95
        throw new NotImplementedException('getBody is not implemented');
96
    }
97
98
    public function getStatusCode()
99
    {
100
        throw new NotImplementedException('getStatusCode is not implemented');
101
    }
102
}
103