1 | <?php |
||
21 | class Result |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Response code |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | protected $_code = 200; |
||
30 | |||
31 | /** |
||
32 | * Response data |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $_data = null; |
||
37 | |||
38 | /** |
||
39 | * Response payload |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $_payload = []; |
||
44 | |||
45 | /** |
||
46 | * Exception structure |
||
47 | * |
||
48 | * @var Exception |
||
49 | */ |
||
50 | protected $_exception = null; |
||
51 | |||
52 | /** |
||
53 | * Result constructor. |
||
54 | * |
||
55 | * @param array $data data to be delivered for the api |
||
56 | * @param int $code code of the api request |
||
57 | */ |
||
58 | 60 | public function __construct($data = null, $code = null) |
|
67 | |||
68 | /** |
||
69 | * Data api method. |
||
70 | * |
||
71 | * @param array $value data to be delivered for the api |
||
72 | * @return array |
||
73 | */ |
||
74 | 56 | public function data($value = null) |
|
83 | |||
84 | /** |
||
85 | * Code api method. |
||
86 | * |
||
87 | * @param int $value code of the api request |
||
88 | * @return int |
||
89 | */ |
||
90 | 60 | public function code($value = null) |
|
99 | |||
100 | /** |
||
101 | * Exception api. |
||
102 | * |
||
103 | * @param Exception $value set the excepltion value |
||
104 | * @return Exception |
||
105 | */ |
||
106 | 56 | public function exception($value = null) |
|
115 | |||
116 | /** |
||
117 | * Payload setter. |
||
118 | * |
||
119 | * @param string $key the key to be setted in the payload |
||
120 | * @param mixed $value value to be setted as payload |
||
121 | * @return void |
||
122 | */ |
||
123 | 30 | public function setPayload($key, $value) |
|
127 | |||
128 | /** |
||
129 | * Payload api method |
||
130 | * |
||
131 | * @param string $key the key to get the payload |
||
132 | * @return mixed |
||
133 | */ |
||
134 | 54 | public function payload($key = null) |
|
145 | |||
146 | public function toArray() |
||
159 | |||
160 | /** |
||
161 | * Returns an array that can be used to describe the internal state of this |
||
162 | * object. |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | public function __debugInfo() |
||
170 | |||
171 | } |
||
172 |