ResponseException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getResponse() 0 3 1
1
<?php
2
/**
3
 * This file is part of graze/gigya-client
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/gigya-client/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/gigya-client
12
 */
13
14
namespace Graze\Gigya\Exception;
15
16
use Exception;
17
use Graze\Gigya\Response\ResponseInterface;
18
use RuntimeException;
19
20
/**
21
 * Class ResponseException.
22
 *
23
 * Generic Response Exception
24
 */
25
class ResponseException extends RuntimeException
26
{
27
    /**
28
     * @var ResponseInterface
29
     */
30
    protected $response;
31
32
    /**
33
     * @param ResponseInterface $response
34
     * @param string            $message
35
     * @param Exception|null    $previous
36
     */
37 8
    public function __construct(ResponseInterface $response, $message = '', Exception $previous = null)
38
    {
39 8
        $this->response = $response;
40
41 8
        $message = (($message) ? $message . "\n" : '') .
42 8
            $response;
43
44 8
        parent::__construct($message, $response->getErrorCode(), $previous);
45 8
    }
46
47
    /**
48
     * @return ResponseInterface
49
     */
50 1
    public function getResponse()
51
    {
52 1
        return $this->response;
53
    }
54
}
55