@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Haeders |
35 | 35 | * @var array |
36 | 36 | */ |
37 | - protected $headers = []; |
|
37 | + protected $headers = [ ]; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $this->lang = \App::getLocale(); |
57 | 57 | |
58 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
58 | + $this->config = include __DIR__.'/../errors/lang/'.$this->lang.'.php'; |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @uses |
82 | 82 | * @see |
83 | 83 | */ |
84 | - public function setStatusCode( $statusCode ) { |
|
84 | + public function setStatusCode($statusCode) { |
|
85 | 85 | |
86 | 86 | $this->statusCode = $statusCode; |
87 | 87 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @uses |
112 | 112 | * @see |
113 | 113 | */ |
114 | - public function setStatusText( $statusText ) { |
|
114 | + public function setStatusText($statusText) { |
|
115 | 115 | |
116 | 116 | $this->statusText = $statusText; |
117 | 117 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | * @uses |
129 | 129 | * @see |
130 | 130 | */ |
131 | - public function respond( $data ) { |
|
131 | + public function respond($data) { |
|
132 | 132 | |
133 | - $result = array_filter( $this->getHeaders() ); |
|
133 | + $result = array_filter($this->getHeaders()); |
|
134 | 134 | |
135 | - if ( empty( $result ) ) |
|
136 | - return response()->json( $data, $this->getStatusCode() ); |
|
135 | + if (empty($result)) |
|
136 | + return response()->json($data, $this->getStatusCode()); |
|
137 | 137 | |
138 | - return response()->json( $data, $this->getStatusCode() ) |
|
139 | - ->withHeaders( $this->getHeaders() ); |
|
138 | + return response()->json($data, $this->getStatusCode()) |
|
139 | + ->withHeaders($this->getHeaders()); |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | * @uses |
150 | 150 | * @see |
151 | 151 | */ |
152 | - public function respondWithMessage( $message ) { |
|
152 | + public function respondWithMessage($message) { |
|
153 | 153 | |
154 | 154 | $res[ 'status' ] = $this->getStatusText(); |
155 | 155 | |
156 | 156 | //if it's about failure |
157 | - if ( $this->getErrorCode() ) { |
|
157 | + if ($this->getErrorCode()) { |
|
158 | 158 | |
159 | 159 | $res[ 'error' ] = $this->getErrorCode(); |
160 | 160 | |
161 | - if ( is_null( $message ) ) |
|
161 | + if (is_null($message)) |
|
162 | 162 | $res[ 'message' ] = $this->getErrorMessage(); |
163 | 163 | else |
164 | 164 | $res[ 'message' ] = $message; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | } |
171 | 171 | |
172 | - return $this->respond( $res ); |
|
172 | + return $this->respond($res); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param $errorCode integer |
181 | 181 | * @return instance |
182 | 182 | */ |
183 | - public function setErrorCode( $errorCode ) { |
|
183 | + public function setErrorCode($errorCode) { |
|
184 | 184 | |
185 | 185 | $this->error = $this->config[ $errorCode ]; |
186 | 186 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function getErrorMessage() { |
212 | 212 | |
213 | - return $this->error['message']; |
|
213 | + return $this->error[ 'message' ]; |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @since Sep 13, 2016 |
233 | 233 | * @return array |
234 | 234 | */ |
235 | - public function setHeaders( $headers = [] ) { |
|
235 | + public function setHeaders($headers = [ ]) { |
|
236 | 236 | |
237 | 237 | $this->headers = $headers; |
238 | 238 | |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | * @uses |
250 | 250 | * @see |
251 | 251 | */ |
252 | - public function respondWithResult( $data = NULL ) { |
|
252 | + public function respondWithResult($data = NULL) { |
|
253 | 253 | |
254 | 254 | $res[ 'status' ] = $this->getStatusText(); |
255 | 255 | |
256 | 256 | //if it's about laravel validation error |
257 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
257 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
258 | 258 | |
259 | 259 | $res[ 'error' ] = $this->getErrorCode(); |
260 | 260 | $res[ 'message' ] = $data; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | } |
267 | 267 | |
268 | - return $this->respond( $res ); |
|
268 | + return $this->respond($res); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 |