Response   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 55
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getStatusCode() 0 4 1
A getTimestamp() 0 4 1
A getData() 0 4 1
A getHeader() 0 4 1
A toJSON() 0 8 1
1
<?php
2
3
namespace Parkwayprojects\PayWithBank3D\Controllers;
4
5
class Response
6
{
7
    // The actual Guzzle response:
8
    private $response;
9
10
    // Core response:
11
    private $headers;
12
    private $bodyRaw;
13
    private $body;
14
15
    // Properties:
16
    private $statusCode;
17
    private $timestamp;
18
19
    public function __construct(\GuzzleHttp\Psr7\Response $response)
20
    {
21
        $this->response = $response;
22
        $this->headers = $response->getHeaders();
23
        $this->bodyRaw = (string) $response->getBody();
24
        $this->body = json_decode($this->bodyRaw);
25
26
        // Set our properties:
27
        $this->statusCode = $response->getStatusCode();
28
        $this->timestamp = date('c');
29
    }
30
31
    public function getStatusCode()
32
    {
33
        return (int) $this->statusCode;
34
    }
35
36
    public function getTimestamp()
37
    {
38
        return $this->timestamp;
39
    }
40
41
    public function getData()
42
    {
43
        return $this->body;
44
    }
45
46
    public function getHeader()
47
    {
48
        return $this->headers;
49
    }
50
51
    public function toJSON()
52
    {
53
        return json_encode([
54
            'statusCode'   => $this->getStatusCode(),
55
            'timestamp'    => $this->getTimestamp(),
56
            'body' => $this->getData(),
57
        ], true);
58
    }
59
}
60