ResponseException::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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