ErrorResponseException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __toString() 0 7 1
1
<?php
2
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 * @date 26/08/2016 14:24
5
 */
6
7
namespace Yandex\Direct\Exception;
8
9
/**
10
 * Class ErrorResponseException
11
 * @package Yandex\Direct\Exception
12
 */
13
class ErrorResponseException extends Exception
14
{
15
    /**
16
     * @var int
17
     */
18
    protected $requestId;
19
20
    /**
21
     * @var string
22
     */
23
    protected $details;
24
25
    /**
26
     * @param string $message
27
     * @param string $details
28
     * @param int $code
29
     * @param int $requestId
30
     * @param \Exception $previous
31
     */
32
    public function __construct($message, $details = '', $code = 0, $requestId = 0, \Exception $previous = null)
33
    {
34
        $this->details = $details;
35
        $this->requestId = $requestId;
36
        parent::__construct($message, $code, $previous);
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function __toString()
43
    {
44
        $str = 'Exception ' . __CLASS__ . " code {$this->code} with message '{$this->message}' in `{$this->file}`" . PHP_EOL;
45
        $str .= 'Details: ' . $this->details . PHP_EOL;
46
        $str .= 'Stack trace:' . PHP_EOL . $this->getTraceAsString();
47
        return $str;
48
    }
49
}
50