Passed
Push — main ( f53085...dfbcc5 )
by huang
04:16
created

Error::code()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
namespace Xmly\Http;
3
4
/**
5
 * 业务请求逻辑错误封装类,主要用来解析API请求返回如下的内容:
6
 * <pre>
7
 *     {"error" : "detailed error message"}
8
 * </pre>
9
 */
10
final class Error
11
{
12
    private $url;
13
    private $response;
14
15 4
    public function __construct($url, $response)
16
    {
17 4
        $this->url = $url;
18 4
        $this->response = $response;
19 4
    }
20
21 1
    public function code()
22
    {
23 1
        return $this->response->statusCode;
24
    }
25
26 1
    public function getResponse()
27
    {
28 1
        return $this->response;
29
    }
30
31 1
    public function message()
32
    {
33 1
        return $this->response->error;
34
    }
35
}
36