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

RequestException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getType() 0 3 1
A getResponseCode() 0 3 1
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