@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | public function __construct() { |
52 | 52 | |
53 | 53 | |
54 | - if( class_exists('\App')){ |
|
55 | - $this->lang = \App::getLocale(); |
|
56 | - }else{ |
|
57 | - $this->lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
|
58 | - } |
|
54 | + if( class_exists('\App')){ |
|
55 | + $this->lang = \App::getLocale(); |
|
56 | + }else{ |
|
57 | + $this->lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | if(! file_exists(config_path($this->lang . '.php'))){ |
61 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
62 | - } else { |
|
63 | - $this->config = include config_path($this->lang . '.php'); |
|
64 | - } |
|
61 | + $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
62 | + } else { |
|
63 | + $this->config = include config_path($this->lang . '.php'); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $res[ 'error' ] = $this->getErrorCode(); |
166 | 166 | |
167 | 167 | if ( is_null( $message ) ) |
168 | - $res[ 'message' ] = $this->getErrorMessage(); |
|
169 | - else |
|
170 | - $res[ 'message' ] = $message; |
|
168 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
169 | + else |
|
170 | + $res[ 'message' ] = $message; |
|
171 | 171 | |
172 | 172 | } else { |
173 | 173 |
@@ -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 |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | public function __construct() { |
52 | 52 | |
53 | 53 | |
54 | - if( class_exists('\App')){ |
|
54 | + if (class_exists('\App')) { |
|
55 | 55 | $this->lang = \App::getLocale(); |
56 | - }else{ |
|
56 | + } else { |
|
57 | 57 | $this->lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
58 | 58 | } |
59 | 59 | |
60 | - if(! file_exists(config_path($this->lang . '.php'))){ |
|
60 | + if (!file_exists(config_path($this->lang . '.php'))) { |
|
61 | 61 | $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
62 | 62 | } else { |
63 | 63 | $this->config = include config_path($this->lang . '.php'); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @uses |
88 | 88 | * @see |
89 | 89 | */ |
90 | - public function setStatusCode( $statusCode ) { |
|
90 | + public function setStatusCode($statusCode) { |
|
91 | 91 | |
92 | 92 | $this->statusCode = $statusCode; |
93 | 93 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @uses |
118 | 118 | * @see |
119 | 119 | */ |
120 | - public function setStatusText( $statusText ) { |
|
120 | + public function setStatusText($statusText) { |
|
121 | 121 | |
122 | 122 | $this->statusText = $statusText; |
123 | 123 | |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | * @uses |
135 | 135 | * @see |
136 | 136 | */ |
137 | - public function respond( $data ) { |
|
137 | + public function respond($data) { |
|
138 | 138 | |
139 | - $result = array_filter( $this->getHeaders() ); |
|
139 | + $result = array_filter($this->getHeaders()); |
|
140 | 140 | |
141 | - if ( empty( $result ) ) |
|
142 | - return response()->json( $data, $this->getStatusCode() ); |
|
141 | + if (empty($result)) |
|
142 | + return response()->json($data, $this->getStatusCode()); |
|
143 | 143 | |
144 | - return response()->json( $data, $this->getStatusCode() ) |
|
145 | - ->withHeaders( $this->getHeaders() ); |
|
144 | + return response()->json($data, $this->getStatusCode()) |
|
145 | + ->withHeaders($this->getHeaders()); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @uses |
156 | 156 | * @see |
157 | 157 | */ |
158 | - public function respondWithMessage( $message = null ) { |
|
158 | + public function respondWithMessage($message = null) { |
|
159 | 159 | |
160 | 160 | $res[ 'status' ] = $this->getStatusText(); |
161 | 161 | |
162 | 162 | //if it's about failure |
163 | - if ( $this->getErrorCode() ) { |
|
163 | + if ($this->getErrorCode()) { |
|
164 | 164 | |
165 | 165 | $res[ 'error' ] = $this->getErrorCode(); |
166 | 166 | |
167 | - if ( is_null( $message ) ) |
|
167 | + if (is_null($message)) |
|
168 | 168 | $res[ 'message' ] = $this->getErrorMessage(); |
169 | 169 | else |
170 | 170 | $res[ 'message' ] = $message; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | } |
177 | 177 | |
178 | - return $this->respond( $res ); |
|
178 | + return $this->respond($res); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param $errorCode integer |
187 | 187 | * @return $this |
188 | 188 | */ |
189 | - public function setErrorCode( $errorCode ) { |
|
189 | + public function setErrorCode($errorCode) { |
|
190 | 190 | |
191 | 191 | $this->error = $this->config[ $errorCode ]; |
192 | 192 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function getErrorMessage() { |
218 | 218 | |
219 | - return $this->error['message']; |
|
219 | + return $this->error[ 'message' ]; |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @since Sep 13, 2016 |
239 | 239 | * @return $this |
240 | 240 | */ |
241 | - public function setHeaders( $headers = [] ) { |
|
241 | + public function setHeaders($headers = [ ]) { |
|
242 | 242 | |
243 | 243 | $this->headers = $headers; |
244 | 244 | |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | * @uses |
256 | 256 | * @see |
257 | 257 | */ |
258 | - public function respondWithResult( $data = NULL ) { |
|
258 | + public function respondWithResult($data = NULL) { |
|
259 | 259 | |
260 | 260 | $res[ 'status' ] = $this->getStatusText(); |
261 | 261 | |
262 | 262 | //if it's about laravel validation error |
263 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
263 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
264 | 264 | |
265 | 265 | $res[ 'error' ] = $this->getErrorCode(); |
266 | 266 | $res[ 'message' ] = $data; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - return $this->respond( $res ); |
|
274 | + return $this->respond($res); |
|
275 | 275 | |
276 | 276 | } |
277 | 277 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | if( class_exists('\App')){ |
55 | 55 | $this->lang = \App::getLocale(); |
56 | - }else{ |
|
56 | + } else{ |
|
57 | 57 | $this->lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
58 | 58 | } |
59 | 59 | |
@@ -138,8 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | $result = array_filter( $this->getHeaders() ); |
140 | 140 | |
141 | - if ( empty( $result ) ) |
|
142 | - return response()->json( $data, $this->getStatusCode() ); |
|
141 | + if ( empty( $result ) ) { |
|
142 | + return response()->json( $data, $this->getStatusCode() ); |
|
143 | + } |
|
143 | 144 | |
144 | 145 | return response()->json( $data, $this->getStatusCode() ) |
145 | 146 | ->withHeaders( $this->getHeaders() ); |
@@ -164,10 +165,11 @@ discard block |
||
164 | 165 | |
165 | 166 | $res[ 'error' ] = $this->getErrorCode(); |
166 | 167 | |
167 | - if ( is_null( $message ) ) |
|
168 | - $res[ 'message' ] = $this->getErrorMessage(); |
|
169 | - else |
|
170 | - $res[ 'message' ] = $message; |
|
168 | + if ( is_null( $message ) ) { |
|
169 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
170 | + } else { |
|
171 | + $res[ 'message' ] = $message; |
|
172 | + } |
|
171 | 173 | |
172 | 174 | } else { |
173 | 175 |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | class RespondServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | 9 | /** |
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | 14 | public function boot() |
15 | 15 | { |
16 | 16 | |
17 | - if( class_exists('\App')){ |
|
18 | - $lang = \App::getLocale(); |
|
19 | - }else{ |
|
20 | - $lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
|
21 | - } |
|
17 | + if( class_exists('\App')){ |
|
18 | + $lang = \App::getLocale(); |
|
19 | + }else{ |
|
20 | + $lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | $this->publishes([ |
24 | 24 | __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
31 | - * Register any package services. |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
31 | + * Register any package services. |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | 35 | public function register() |
36 | 36 | { |
37 | 37 |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | public function boot() |
15 | 15 | { |
16 | 16 | |
17 | - if( class_exists('\App')){ |
|
17 | + if (class_exists('\App')) { |
|
18 | 18 | $lang = \App::getLocale(); |
19 | - }else{ |
|
19 | + } else { |
|
20 | 20 | $lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
21 | 21 | } |
22 | 22 | |
23 | 23 | $this->publishes([ |
24 | - __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
24 | + __DIR__ . '/../errors/lang/' . $lang . '.php' => config_path($lang . '.php'), |
|
25 | 25 | ]); |
26 | 26 | |
27 | 27 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | private function registerMessages() |
43 | 43 | { |
44 | 44 | |
45 | - $this->app->bind( 'Vahid\Respond\Messages', function() { |
|
45 | + $this->app->bind('Vahid\Respond\Messages', function() { |
|
46 | 46 | |
47 | 47 | return new Messages(); |
48 | 48 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | if( class_exists('\App')){ |
18 | 18 | $lang = \App::getLocale(); |
19 | - }else{ |
|
19 | + } else{ |
|
20 | 20 | $lang = /** @scrutinizer ignore-call */ app('translator')->getLocale(); |
21 | 21 | } |
22 | 22 |