Passed
Pull Request — master (#13)
by Andrey
04:37
created

RequestException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: gorkalaucirica
5
 * Date: 09/07/14
6
 * Time: 12:33
7
 */
8
9
namespace SolutionDrive\HipchatAPIv2Client\Exception;
10
11
12
class RequestException extends \Exception implements RequestExceptionInterface
13
{
14
    protected $responseCode;
15
16
    protected $message;
17
18
    protected $type;
19
20
    /**
21
     * Request exception constructor
22
     *
23
     * @param string $response json_decoded array with the error response given by the server
24
     */
25 4
    public function __construct($response)
26
    {
27 4
        $error = $response['error'];
28 4
        $this->responseCode = $error['code'];
29 4
        $this->message = $error['message'];
30 4
        $this->type = $error['type'];
31 4
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 1
    public function getResponseCode()
37
    {
38 1
        return $this->responseCode;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 1
    public function getType()
45
    {
46 1
        return $this->type;
47
    }
48
}
49