Completed
Push — master ( 325c35...2c35c6 )
by Jared
02:19
created

JCResponse::headers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: jaredchu
5
 * Date: 31/05/2017
6
 * Time: 09:50
7
 */
8
9
namespace JC;
10
11
12
use Psr\Http\Message\ResponseInterface;
13
use GuzzleHttp;
14
15
class JCResponse implements iJCResponse
16
{
17
18
    /**
19
     * @var ResponseInterface
20
     */
21
    public $response;
22
23
    /**
24
     * @var string
25
     */
26
    protected $body;
27
28
    /**
29
     * JCResponse constructor.
30
     * @param $response
31
     */
32 6
    public function __construct($response)
33
    {
34 6
        $this->response = $response;
35 6
        $this->body = $this->response->getBody()->getContents();
36 6
    }
37
38
39 6
    public function status()
40
    {
41 6
        return $this->response->getStatusCode();
42
    }
43
44 6
    public function body()
45
    {
46 6
        return $this->body;
47
    }
48
49 1
    public function headers()
50
    {
51 1
        return $this->response->getHeaders();
52
    }
53
54 5
    public function json()
55
    {
56 5
        return GuzzleHttp\json_decode($this->body());
57
    }
58
}