@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | * @uses |
| 15 | 15 | * @see |
| 16 | 16 | */ |
| 17 | - public function succeed( $data ) { |
|
| 17 | + public function succeed($data) { |
|
| 18 | 18 | |
| 19 | - return $this->setStatusCode( 200 ) |
|
| 20 | - ->setStatusText( 'success' ) |
|
| 21 | - ->respondWithResult( $data ); |
|
| 19 | + return $this->setStatusCode(200) |
|
| 20 | + ->setStatusText('success') |
|
| 21 | + ->respondWithResult($data); |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * @uses |
| 31 | 31 | * @see |
| 32 | 32 | */ |
| 33 | - public function deleteSucceeded( $message ) { |
|
| 33 | + public function deleteSucceeded($message) { |
|
| 34 | 34 | |
| 35 | - if ( empty( $message ) ) |
|
| 35 | + if (empty($message)) |
|
| 36 | 36 | $message = $this->config[ 'success' ][ 'delete' ]; |
| 37 | 37 | |
| 38 | - return $this->setStatusCode( 200 ) |
|
| 39 | - ->setStatusText( 'success' ) |
|
| 40 | - ->respondWithMessage( $message ); |
|
| 38 | + return $this->setStatusCode(200) |
|
| 39 | + ->setStatusText('success') |
|
| 40 | + ->respondWithMessage($message); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | * @uses |
| 50 | 50 | * @see |
| 51 | 51 | */ |
| 52 | - public function updateSucceeded( $message ) { |
|
| 52 | + public function updateSucceeded($message) { |
|
| 53 | 53 | |
| 54 | - if ( empty( $message ) ) |
|
| 54 | + if (empty($message)) |
|
| 55 | 55 | $message = $this->config[ 'success' ][ 'update' ]; |
| 56 | 56 | |
| 57 | - return $this->setStatusCode( 200 ) |
|
| 58 | - ->setStatusText( 'success' ) |
|
| 59 | - ->respondWithMessage( $message ); |
|
| 57 | + return $this->setStatusCode(200) |
|
| 58 | + ->setStatusText('success') |
|
| 59 | + ->respondWithMessage($message); |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | * @uses |
| 69 | 69 | * @see |
| 70 | 70 | */ |
| 71 | - public function insertSucceeded( $message ) { |
|
| 71 | + public function insertSucceeded($message) { |
|
| 72 | 72 | |
| 73 | - if ( empty( $message ) ) |
|
| 73 | + if (empty($message)) |
|
| 74 | 74 | $message = $this->config[ 'success' ][ 'insert' ]; |
| 75 | 75 | |
| 76 | - return $this->setStatusCode( 200 ) |
|
| 77 | - ->setStatusText( $this->config[ 'success' ][ 'message' ] ) |
|
| 78 | - ->respondWithMessage( $message ); |
|
| 76 | + return $this->setStatusCode(200) |
|
| 77 | + ->setStatusText($this->config[ 'success' ][ 'message' ]) |
|
| 78 | + ->respondWithMessage($message); |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * @uses |
| 88 | 88 | * @see |
| 89 | 89 | */ |
| 90 | - public function deleteFaild( $message ) { |
|
| 90 | + public function deleteFaild($message) { |
|
| 91 | 91 | |
| 92 | - return $this->setStatusCode( 447 ) |
|
| 93 | - ->setStatusText( 'fail' ) |
|
| 94 | - ->setErrorCode( 5447 ) |
|
| 95 | - ->respondWithMessage( $message ); |
|
| 92 | + return $this->setStatusCode(447) |
|
| 93 | + ->setStatusText('fail') |
|
| 94 | + ->setErrorCode(5447) |
|
| 95 | + ->respondWithMessage($message); |
|
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function updateFaild() { |
| 108 | 108 | |
| 109 | - return $this->setStatusCode( 449 ) |
|
| 110 | - ->setStatusText( 'fail' ) |
|
| 111 | - ->setErrorCode( 5449 ) |
|
| 109 | + return $this->setStatusCode(449) |
|
| 110 | + ->setStatusText('fail') |
|
| 111 | + ->setErrorCode(5449) |
|
| 112 | 112 | ->respondWithMessage(); |
| 113 | 113 | |
| 114 | 114 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function insertFaild() { |
| 125 | 125 | |
| 126 | - return $this->setStatusCode( 448 ) |
|
| 127 | - ->setStatusText( 'fail' ) |
|
| 128 | - ->setErrorCode( 5448 ) |
|
| 126 | + return $this->setStatusCode(448) |
|
| 127 | + ->setStatusText('fail') |
|
| 128 | + ->setErrorCode(5448) |
|
| 129 | 129 | ->respondWithMessage(); |
| 130 | 130 | |
| 131 | 131 | } |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function connectionRefused() { |
| 142 | 142 | |
| 143 | - return $this->setStatusCode( 445 ) |
|
| 144 | - ->setStatusText( 'fail' ) |
|
| 145 | - ->setErrorCode( 5445 ) |
|
| 143 | + return $this->setStatusCode(445) |
|
| 144 | + ->setStatusText('fail') |
|
| 145 | + ->setErrorCode(5445) |
|
| 146 | 146 | ->respondWithMessage(); |
| 147 | 147 | |
| 148 | 148 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function notFound() { |
| 159 | 159 | |
| 160 | - return $this->setStatusCode( 404 ) |
|
| 161 | - ->setStatusText( 'fail' ) |
|
| 162 | - ->setErrorCode( 5404 ) |
|
| 160 | + return $this->setStatusCode(404) |
|
| 161 | + ->setStatusText('fail') |
|
| 162 | + ->setErrorCode(5404) |
|
| 163 | 163 | ->respondWithMessage(); |
| 164 | 164 | |
| 165 | 165 | } |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function wrongParameters() { |
| 176 | 176 | |
| 177 | - return $this->setStatusCode( 406 ) |
|
| 178 | - ->setStatusText( 'fail' ) |
|
| 179 | - ->setErrorCode( 5406 ) |
|
| 177 | + return $this->setStatusCode(406) |
|
| 178 | + ->setStatusText('fail') |
|
| 179 | + ->setErrorCode(5406) |
|
| 180 | 180 | ->respondWithMessage(); |
| 181 | 181 | |
| 182 | 182 | } |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function methodNotAllowed() { |
| 193 | 193 | |
| 194 | - return $this->setStatusCode( 405 ) |
|
| 195 | - ->setStatusText( 'fail' ) |
|
| 196 | - ->setErrorCode( 5405 ) |
|
| 194 | + return $this->setStatusCode(405) |
|
| 195 | + ->setStatusText('fail') |
|
| 196 | + ->setErrorCode(5405) |
|
| 197 | 197 | ->respondWithMessage(); |
| 198 | 198 | |
| 199 | 199 | } |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | * @uses |
| 207 | 207 | * @see |
| 208 | 208 | */ |
| 209 | - public function validationErrors( $data ) { |
|
| 209 | + public function validationErrors($data) { |
|
| 210 | 210 | |
| 211 | - return $this->setStatusCode( 420 ) |
|
| 212 | - ->setStatusText( 'fail' ) |
|
| 213 | - ->setErrorCode( 5420 ) |
|
| 214 | - ->respondWithResult( $data ); |
|
| 211 | + return $this->setStatusCode(420) |
|
| 212 | + ->setStatusText('fail') |
|
| 213 | + ->setErrorCode(5420) |
|
| 214 | + ->respondWithResult($data); |
|
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function requestFieldNotFound() { |
| 227 | 227 | |
| 228 | - return $this->setStatusCode( 446 ) |
|
| 229 | - ->setStatusText( 'fail' ) |
|
| 230 | - ->setErrorCode( 1001 ) |
|
| 228 | + return $this->setStatusCode(446) |
|
| 229 | + ->setStatusText('fail') |
|
| 230 | + ->setErrorCode(1001) |
|
| 231 | 231 | ->respondWithMessage(); |
| 232 | 232 | |
| 233 | 233 | } |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function requestFieldDuplicated() { |
| 242 | 242 | |
| 243 | - return $this->setStatusCode( 400 ) |
|
| 244 | - ->setStatusText( 'fail' ) |
|
| 243 | + return $this->setStatusCode(400) |
|
| 244 | + ->setStatusText('fail') |
|
| 245 | 245 | ->SetErrorCode(1004) |
| 246 | 246 | ->respondWithMessage(); |
| 247 | 247 | |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | * @param $code integer |
| 255 | 255 | * @return json |
| 256 | 256 | */ |
| 257 | - public function error( $code ) { |
|
| 257 | + public function error($code) { |
|
| 258 | 258 | |
| 259 | - return $this->SetStatusCode( 400 ) |
|
| 260 | - ->setStatusText( 'fail' ) |
|
| 261 | - ->setErrorCode( $code ) |
|
| 259 | + return $this->SetStatusCode(400) |
|
| 260 | + ->setStatusText('fail') |
|
| 261 | + ->setErrorCode($code) |
|
| 262 | 262 | ->respondWithMessage(); |
| 263 | 263 | |
| 264 | 264 | } |
@@ -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 |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $this->lang = \App::getLocale(); |
| 56 | 56 | |
| 57 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
| 57 | + $this->config = include __DIR__.'/../errors/lang/'.$this->lang.'.php'; |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @uses |
| 81 | 81 | * @see |
| 82 | 82 | */ |
| 83 | - public function setStatusCode( $statusCode ) { |
|
| 83 | + public function setStatusCode($statusCode) { |
|
| 84 | 84 | |
| 85 | 85 | $this->statusCode = $statusCode; |
| 86 | 86 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @uses |
| 111 | 111 | * @see |
| 112 | 112 | */ |
| 113 | - public function setStatusText( $statusText ) { |
|
| 113 | + public function setStatusText($statusText) { |
|
| 114 | 114 | |
| 115 | 115 | $this->statusText = $statusText; |
| 116 | 116 | |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | * @uses |
| 128 | 128 | * @see |
| 129 | 129 | */ |
| 130 | - public function respond( $data ) { |
|
| 130 | + public function respond($data) { |
|
| 131 | 131 | |
| 132 | - $result = array_filter( $this->getHeaders() ); |
|
| 132 | + $result = array_filter($this->getHeaders()); |
|
| 133 | 133 | |
| 134 | - if ( empty( $result ) ) |
|
| 135 | - return response()->json( $data, $this->getStatusCode() ); |
|
| 134 | + if (empty($result)) |
|
| 135 | + return response()->json($data, $this->getStatusCode()); |
|
| 136 | 136 | |
| 137 | - return response()->json( $data, $this->getStatusCode() ) |
|
| 138 | - ->withHeaders( $this->getHeaders() ); |
|
| 137 | + return response()->json($data, $this->getStatusCode()) |
|
| 138 | + ->withHeaders($this->getHeaders()); |
|
| 139 | 139 | |
| 140 | 140 | } |
| 141 | 141 | |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | * @uses |
| 149 | 149 | * @see |
| 150 | 150 | */ |
| 151 | - public function respondWithMessage( $message ) { |
|
| 151 | + public function respondWithMessage($message) { |
|
| 152 | 152 | |
| 153 | 153 | $res[ 'status' ] = $this->getStatusText(); |
| 154 | 154 | |
| 155 | 155 | //if it's about failure |
| 156 | - if ( $this->getErrorCode() ) { |
|
| 156 | + if ($this->getErrorCode()) { |
|
| 157 | 157 | |
| 158 | 158 | $res[ 'error' ] = $this->getErrorCode(); |
| 159 | 159 | |
| 160 | - if ( empty( $message ) ) |
|
| 160 | + if (empty($message)) |
|
| 161 | 161 | $res[ 'message' ] = $this->getErrorMessage(); |
| 162 | 162 | |
| 163 | 163 | $res[ 'message' ] = $message; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return $this->respond( $res ); |
|
| 171 | + return $this->respond($res); |
|
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param $errorCode integer |
| 180 | 180 | * @return instance |
| 181 | 181 | */ |
| 182 | - public function setErrorCode( $errorCode ) { |
|
| 182 | + public function setErrorCode($errorCode) { |
|
| 183 | 183 | |
| 184 | 184 | $this->error = $this->config[ $errorCode ]; |
| 185 | 185 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function getErrorMessage() { |
| 211 | 211 | |
| 212 | - return $this->error['message']; |
|
| 212 | + return $this->error[ 'message' ]; |
|
| 213 | 213 | |
| 214 | 214 | } |
| 215 | 215 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @since Sep 13, 2016 |
| 232 | 232 | * @return array |
| 233 | 233 | */ |
| 234 | - public function setHeaders( $headers = [] ) { |
|
| 234 | + public function setHeaders($headers = [ ]) { |
|
| 235 | 235 | |
| 236 | 236 | $this->headers = $headers; |
| 237 | 237 | |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | * @uses |
| 249 | 249 | * @see |
| 250 | 250 | */ |
| 251 | - public function respondWithResult( $data = NULL ) { |
|
| 251 | + public function respondWithResult($data = NULL) { |
|
| 252 | 252 | |
| 253 | 253 | $res[ 'status' ] = $this->getStatusText(); |
| 254 | 254 | |
| 255 | 255 | //if it's about laravel validation error |
| 256 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
| 256 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
| 257 | 257 | |
| 258 | 258 | $res[ 'error' ] = $this->getErrorCode(); |
| 259 | 259 | $res[ 'message' ] = $data; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - return $this->respond( $res ); |
|
| 267 | + return $this->respond($res); |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $lang = \App::getLocale(); |
| 18 | 18 | |
| 19 | 19 | $this->publishes([ |
| 20 | - __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
| 20 | + __DIR__.'/../errors/lang/'.$lang.'.php' => config_path($lang.'.php'), |
|
| 21 | 21 | ]); |
| 22 | 22 | |
| 23 | 23 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | private function registerMessages() |
| 39 | 39 | { |
| 40 | 40 | |
| 41 | - $this->app->bind( 'Anetwork\Respond\Messages', function() { |
|
| 41 | + $this->app->bind('Anetwork\Respond\Messages', function() { |
|
| 42 | 42 | |
| 43 | 43 | return new Messages(); |
| 44 | 44 | |