@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * Haeders |
33 | 33 | * @var array |
34 | 34 | */ |
35 | - protected $headers = []; |
|
35 | + protected $headers = [ ]; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var string |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | |
54 | 54 | $this->lang = \App::getLocale(); |
55 | 55 | |
56 | - if(! file_exists(config_path($this->lang . '.php'))){ |
|
57 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
56 | + if (!file_exists(config_path($this->lang.'.php'))) { |
|
57 | + $this->config = include __DIR__.'/../errors/lang/'.$this->lang.'.php'; |
|
58 | 58 | } else { |
59 | - $this->config = include config_path($this->lang . '.php'); |
|
59 | + $this->config = include config_path($this->lang.'.php'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @uses |
84 | 84 | * @see |
85 | 85 | */ |
86 | - public function setStatusCode( $statusCode ) { |
|
86 | + public function setStatusCode($statusCode) { |
|
87 | 87 | |
88 | 88 | $this->statusCode = $statusCode; |
89 | 89 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @uses |
114 | 114 | * @see |
115 | 115 | */ |
116 | - public function setStatusText( $statusText ) { |
|
116 | + public function setStatusText($statusText) { |
|
117 | 117 | |
118 | 118 | $this->statusText = $statusText; |
119 | 119 | |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @uses |
131 | 131 | * @see |
132 | 132 | */ |
133 | - public function respond( $data ) { |
|
133 | + public function respond($data) { |
|
134 | 134 | |
135 | - $result = array_filter( $this->getHeaders() ); |
|
135 | + $result = array_filter($this->getHeaders()); |
|
136 | 136 | |
137 | - if ( empty( $result ) ) |
|
138 | - return response()->json( $data, $this->getStatusCode() ); |
|
137 | + if (empty($result)) |
|
138 | + return response()->json($data, $this->getStatusCode()); |
|
139 | 139 | |
140 | - return response()->json( $data, $this->getStatusCode() ) |
|
141 | - ->withHeaders( $this->getHeaders() ); |
|
140 | + return response()->json($data, $this->getStatusCode()) |
|
141 | + ->withHeaders($this->getHeaders()); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | * @uses |
152 | 152 | * @see |
153 | 153 | */ |
154 | - public function respondWithMessage( $message = null ) { |
|
154 | + public function respondWithMessage($message = null) { |
|
155 | 155 | |
156 | 156 | $res[ 'status' ] = $this->getStatusText(); |
157 | 157 | |
158 | 158 | //if it's about failure |
159 | - if ( $this->getErrorCode() ) { |
|
159 | + if ($this->getErrorCode()) { |
|
160 | 160 | |
161 | 161 | $res[ 'error' ] = $this->getErrorCode(); |
162 | 162 | |
163 | - if ( is_null( $message ) ) |
|
163 | + if (is_null($message)) |
|
164 | 164 | $res[ 'message' ] = $this->getErrorMessage(); |
165 | 165 | else |
166 | 166 | $res[ 'message' ] = $message; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | - return $this->respond( $res ); |
|
174 | + return $this->respond($res); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param $errorCode integer |
183 | 183 | * @return $this |
184 | 184 | */ |
185 | - public function setErrorCode( $errorCode ) { |
|
185 | + public function setErrorCode($errorCode) { |
|
186 | 186 | |
187 | 187 | $this->error = $this->config[ $errorCode ]; |
188 | 188 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function getErrorMessage() { |
214 | 214 | |
215 | - return $this->error['message']; |
|
215 | + return $this->error[ 'message' ]; |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @since Sep 13, 2016 |
235 | 235 | * @return array |
236 | 236 | */ |
237 | - public function setHeaders( $headers = [] ) { |
|
237 | + public function setHeaders($headers = [ ]) { |
|
238 | 238 | |
239 | 239 | $this->headers = $headers; |
240 | 240 | |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * @uses |
252 | 252 | * @see |
253 | 253 | */ |
254 | - public function respondWithResult( $data = NULL ) { |
|
254 | + public function respondWithResult($data = NULL) { |
|
255 | 255 | |
256 | 256 | $res[ 'status' ] = $this->getStatusText(); |
257 | 257 | |
258 | 258 | //if it's about laravel validation error |
259 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
259 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
260 | 260 | |
261 | 261 | $res[ 'error' ] = $this->getErrorCode(); |
262 | 262 | $res[ 'message' ] = $data; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | - return $this->respond( $res ); |
|
270 | + return $this->respond($res); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 |