GraphQLException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getErrors() 0 4 1
1
<?php
2
3
namespace Postpay\Exceptions;
4
5
use Postpay\Http\Response;
6
7
class GraphQLException extends ApiException
8
{
9
    /**
10
     * @const string Error key returned.
11
     */
12
    const ERROR_KEY = 'errors';
13
14
    /**
15
     * @var array The decoded JSON response errors.
16
     */
17
    protected $errors = [];
18
19
    /**
20
     * Creates a RESTfulException.
21
     *
22
     * @param Response $response The response that threw the exception.
23
     */
24 1
    public function __construct(Response $response)
25
    {
26 1
        $this->response = $response;
27 1
        $this->decodedBody = $response->json();
28 1
        $this->errors = $this->decodedBody[self::ERROR_KEY];
29 1
        parent::__construct('GraphQL Error.');
30 1
    }
31
32
    /**
33
     * Return the JSON response errors.
34
     *
35
     * @return array
36
     */
37 1
    public function getErrors()
38
    {
39 1
        return $this->errors;
40
    }
41
}
42