Passed
Push — master ( 5911e9...52488d )
by Joao Gilberto
31s
created

BaseException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 4
1
<?php
2
/**
3
 * User: jg
4
 * Date: 23/05/17
5
 * Time: 15:27
6
 */
7
8
namespace ByJG\Swagger\Exception;
9
10
class BaseException extends \Exception
11
{
12
    protected $body;
13
14
    public function __construct($message = "", $body = [], $code = 0, \Throwable $previous = null)
15
    {
16
        $this->body = $body;
17
        if (!empty($body)) {
18
            $message = $message . " ->\n" . json_encode($body, JSON_PRETTY_PRINT) . "\n";
19
        }
20
        parent::__construct($message, $code, $previous);
21
    }
22
23
    /**
24
     * @return mixed
25
     */
26
    public function getBody()
27
    {
28
        return $this->body;
29
    }
30
31
    /**
32
     * @param mixed $body
33
     */
34
    public function setBody($body)
35
    {
36
        $this->body = $body;
37
    }
38
}
39