Passed
Push — master ( c4fb31...6466f2 )
by Antônio
01:43
created

RespostaException::__construct()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 6
nop 2
dl 0
loc 14
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace OBRSDK\Exceptions;
10
11
/**
12
 * Description of BaseExceptions
13
 *
14
 * @author Antonio
15
 */
16
class RespostaException extends \Exception {
17
18
    private $status;
19
    private $titulo;
20
    private $mensagem;
21
    private $error;
22
    private $show;
23
24
    public function __construct($response, $show = null) {
25
        $body = json_decode($response);
26
27
        foreach ($body as $key => $value) {
28
            if (property_exists($this, $key)) {
29
                $this->$key = $value;
30
            }
31
        }
32
33
        if ($show != null) {
34
            $this->show = null;
35
        }
36
37
        parent::__construct($this->mensagem);
38
    }
39
40
    public function getStatus() {
41
        return $this->status;
42
    }
43
44
    public function getTitulo() {
45
        return $this->titulo;
46
    }
47
48
    public function getMensagem() {
49
        return $this->mensagem;
50
    }
51
52
    /**
53
     * 
54
     * @return object
55
     */
56
    public function getError() {
57
        return $this->error;
58
    }
59
60
    public function getShow() {
61
        return $this->show;
62
    }
63
64
}
65