@@ -6,267 +6,267 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Main { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Http status code |
|
| 11 | - * @var integer |
|
| 12 | - */ |
|
| 13 | - protected $statusCode = 200; |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * Status text |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $statusText = 'success'; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Error code, message and text-key |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - protected $error; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Error code |
|
| 29 | - * @var integer |
|
| 30 | - */ |
|
| 31 | - protected $errorCode; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Haeders |
|
| 35 | - * @var array |
|
| 36 | - */ |
|
| 37 | - protected $headers = []; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - protected $lang; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var arry |
|
| 46 | - */ |
|
| 47 | - protected $config; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @author Shahrokh Niakan <[email protected]> |
|
| 51 | - * @since Sep 24, 2016 |
|
| 52 | - */ |
|
| 53 | - public function __construct() { |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - $this->lang = \App::getLocale(); |
|
| 57 | - |
|
| 58 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Getter for $statusCode |
|
| 64 | - * @author Shima Payro <[email protected]> |
|
| 65 | - * @since May 2, 2016 9:46:27 AM |
|
| 66 | - * @uses |
|
| 67 | - * @see |
|
| 68 | - */ |
|
| 69 | - public function getStatusCode() { |
|
| 70 | - |
|
| 71 | - return $this->statusCode; |
|
| 72 | - |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Setter for $statusCode |
|
| 77 | - * @param integer $statusCode |
|
| 78 | - * @return App\Htpp\Responds\Respond |
|
| 79 | - * @author Shima Payro <[email protected]> |
|
| 80 | - * @since May 2, 2016 9:47:04 AM |
|
| 81 | - * @uses |
|
| 82 | - * @see |
|
| 83 | - */ |
|
| 84 | - public function setStatusCode( $statusCode ) { |
|
| 85 | - |
|
| 86 | - $this->statusCode = $statusCode; |
|
| 87 | - |
|
| 88 | - return $this; |
|
| 89 | - |
|
| 90 | - } |
|
| 9 | + /** |
|
| 10 | + * Http status code |
|
| 11 | + * @var integer |
|
| 12 | + */ |
|
| 13 | + protected $statusCode = 200; |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * Status text |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $statusText = 'success'; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Error code, message and text-key |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + protected $error; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Error code |
|
| 29 | + * @var integer |
|
| 30 | + */ |
|
| 31 | + protected $errorCode; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Haeders |
|
| 35 | + * @var array |
|
| 36 | + */ |
|
| 37 | + protected $headers = []; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + protected $lang; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var arry |
|
| 46 | + */ |
|
| 47 | + protected $config; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @author Shahrokh Niakan <[email protected]> |
|
| 51 | + * @since Sep 24, 2016 |
|
| 52 | + */ |
|
| 53 | + public function __construct() { |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + $this->lang = \App::getLocale(); |
|
| 57 | + |
|
| 58 | + $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Getter for $statusCode |
|
| 64 | + * @author Shima Payro <[email protected]> |
|
| 65 | + * @since May 2, 2016 9:46:27 AM |
|
| 66 | + * @uses |
|
| 67 | + * @see |
|
| 68 | + */ |
|
| 69 | + public function getStatusCode() { |
|
| 70 | + |
|
| 71 | + return $this->statusCode; |
|
| 72 | + |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Setter for $statusCode |
|
| 77 | + * @param integer $statusCode |
|
| 78 | + * @return App\Htpp\Responds\Respond |
|
| 79 | + * @author Shima Payro <[email protected]> |
|
| 80 | + * @since May 2, 2016 9:47:04 AM |
|
| 81 | + * @uses |
|
| 82 | + * @see |
|
| 83 | + */ |
|
| 84 | + public function setStatusCode( $statusCode ) { |
|
| 85 | + |
|
| 86 | + $this->statusCode = $statusCode; |
|
| 87 | + |
|
| 88 | + return $this; |
|
| 89 | + |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Getter for $statusText |
|
| 94 | - * @author Shima Payro <[email protected]> |
|
| 95 | - * @since May 2, 2016 9:47:36 AM |
|
| 96 | - * @uses |
|
| 97 | - * @see |
|
| 98 | - */ |
|
| 99 | - public function getStatusText() { |
|
| 100 | - |
|
| 101 | - return $this->statusText; |
|
| 92 | + /** |
|
| 93 | + * Getter for $statusText |
|
| 94 | + * @author Shima Payro <[email protected]> |
|
| 95 | + * @since May 2, 2016 9:47:36 AM |
|
| 96 | + * @uses |
|
| 97 | + * @see |
|
| 98 | + */ |
|
| 99 | + public function getStatusText() { |
|
| 100 | + |
|
| 101 | + return $this->statusText; |
|
| 102 | 102 | |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Setter for $statusText |
|
| 107 | - * @param String $statusText |
|
| 108 | - * @return App\HtppApp\Htpp\Responds\Respond |
|
| 109 | - * @author Shima Payro <[email protected]> |
|
| 110 | - * @since May 2, 2016 9:48:23 AM |
|
| 111 | - * @uses |
|
| 112 | - * @see |
|
| 113 | - */ |
|
| 114 | - public function setStatusText( $statusText ) { |
|
| 105 | + /** |
|
| 106 | + * Setter for $statusText |
|
| 107 | + * @param String $statusText |
|
| 108 | + * @return App\HtppApp\Htpp\Responds\Respond |
|
| 109 | + * @author Shima Payro <[email protected]> |
|
| 110 | + * @since May 2, 2016 9:48:23 AM |
|
| 111 | + * @uses |
|
| 112 | + * @see |
|
| 113 | + */ |
|
| 114 | + public function setStatusText( $statusText ) { |
|
| 115 | 115 | |
| 116 | - $this->statusText = $statusText; |
|
| 116 | + $this->statusText = $statusText; |
|
| 117 | 117 | |
| 118 | - return $this; |
|
| 118 | + return $this; |
|
| 119 | 119 | |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Response |
|
| 124 | - * @param json $data |
|
| 125 | - * @return jsom |
|
| 126 | - * @author Shima Payro <[email protected]> |
|
| 127 | - * @since May 2, 2016 9:48:45 AM |
|
| 128 | - * @uses |
|
| 129 | - * @see |
|
| 130 | - */ |
|
| 131 | - public function respond( $data ) { |
|
| 122 | + /** |
|
| 123 | + * Response |
|
| 124 | + * @param json $data |
|
| 125 | + * @return jsom |
|
| 126 | + * @author Shima Payro <[email protected]> |
|
| 127 | + * @since May 2, 2016 9:48:45 AM |
|
| 128 | + * @uses |
|
| 129 | + * @see |
|
| 130 | + */ |
|
| 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 | |
| 143 | - /** |
|
| 144 | - * Response which conteins just a message |
|
| 145 | - * @param string $message |
|
| 146 | - * @author Shima Payro <[email protected]> |
|
| 147 | - * @since May 2, 2016 9:49:21 AM |
|
| 148 | - * @return json |
|
| 149 | - * @uses |
|
| 150 | - * @see |
|
| 151 | - */ |
|
| 152 | - public function respondWithMessage( $message ) { |
|
| 143 | + /** |
|
| 144 | + * Response which conteins just a message |
|
| 145 | + * @param string $message |
|
| 146 | + * @author Shima Payro <[email protected]> |
|
| 147 | + * @since May 2, 2016 9:49:21 AM |
|
| 148 | + * @return json |
|
| 149 | + * @uses |
|
| 150 | + * @see |
|
| 151 | + */ |
|
| 152 | + public function respondWithMessage( $message ) { |
|
| 153 | 153 | |
| 154 | - $res[ 'status' ] = $this->getStatusText(); |
|
| 154 | + $res[ 'status' ] = $this->getStatusText(); |
|
| 155 | 155 | |
| 156 | - //if it's about failure |
|
| 157 | - if ( $this->getErrorCode() ) { |
|
| 156 | + //if it's about failure |
|
| 157 | + if ( $this->getErrorCode() ) { |
|
| 158 | 158 | |
| 159 | - $res[ 'error' ] = $this->getErrorCode(); |
|
| 159 | + $res[ 'error' ] = $this->getErrorCode(); |
|
| 160 | 160 | |
| 161 | - if ( is_null( $message ) ) |
|
| 162 | - $res[ 'message' ] = $this->getErrorMessage(); |
|
| 163 | - else |
|
| 164 | - $res[ 'message' ] = $message; |
|
| 161 | + if ( is_null( $message ) ) |
|
| 162 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
| 163 | + else |
|
| 164 | + $res[ 'message' ] = $message; |
|
| 165 | 165 | |
| 166 | - } else { |
|
| 166 | + } else { |
|
| 167 | 167 | |
| 168 | - $res[ 'message' ] = $message; |
|
| 168 | + $res[ 'message' ] = $message; |
|
| 169 | 169 | |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - return $this->respond( $res ); |
|
| 172 | + return $this->respond( $res ); |
|
| 173 | 173 | |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Set error code in our result |
|
| 178 | - * @author Mehdi Hosseini <[email protected]> |
|
| 179 | - * @since August 24, 2016 |
|
| 180 | - * @param $errorCode integer |
|
| 181 | - * @return instance |
|
| 182 | - */ |
|
| 183 | - public function setErrorCode( $errorCode ) { |
|
| 176 | + /** |
|
| 177 | + * Set error code in our result |
|
| 178 | + * @author Mehdi Hosseini <[email protected]> |
|
| 179 | + * @since August 24, 2016 |
|
| 180 | + * @param $errorCode integer |
|
| 181 | + * @return instance |
|
| 182 | + */ |
|
| 183 | + public function setErrorCode( $errorCode ) { |
|
| 184 | 184 | |
| 185 | - $this->error = $this->config[ $errorCode ]; |
|
| 185 | + $this->error = $this->config[ $errorCode ]; |
|
| 186 | 186 | |
| 187 | - $this->errorCode = $errorCode; |
|
| 187 | + $this->errorCode = $errorCode; |
|
| 188 | 188 | |
| 189 | - return $this; |
|
| 189 | + return $this; |
|
| 190 | 190 | |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Return Error code |
|
| 195 | - * @author Mehdi Hosseini <[email protected]> |
|
| 196 | - * @since August 24, 2016 |
|
| 197 | - * @return integer |
|
| 198 | - */ |
|
| 199 | - public function getErrorCode() { |
|
| 193 | + /** |
|
| 194 | + * Return Error code |
|
| 195 | + * @author Mehdi Hosseini <[email protected]> |
|
| 196 | + * @since August 24, 2016 |
|
| 197 | + * @return integer |
|
| 198 | + */ |
|
| 199 | + public function getErrorCode() { |
|
| 200 | 200 | |
| 201 | - return $this->errorCode; |
|
| 201 | + return $this->errorCode; |
|
| 202 | 202 | |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Get error message |
|
| 207 | - * @author Mehdi Hosseini <[email protected]> |
|
| 208 | - * @since August 24, 2016 |
|
| 209 | - * @return string |
|
| 210 | - */ |
|
| 211 | - public function getErrorMessage() { |
|
| 205 | + /** |
|
| 206 | + * Get error message |
|
| 207 | + * @author Mehdi Hosseini <[email protected]> |
|
| 208 | + * @since August 24, 2016 |
|
| 209 | + * @return string |
|
| 210 | + */ |
|
| 211 | + public function getErrorMessage() { |
|
| 212 | 212 | |
| 213 | - return $this->error['message']; |
|
| 213 | + return $this->error['message']; |
|
| 214 | 214 | |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Get headers |
|
| 219 | - * @author Shima Payro <[email protected]> |
|
| 220 | - * @since Sep 13, 2016 |
|
| 221 | - * @return array |
|
| 222 | - */ |
|
| 223 | - public function getHeaders() { |
|
| 217 | + /** |
|
| 218 | + * Get headers |
|
| 219 | + * @author Shima Payro <[email protected]> |
|
| 220 | + * @since Sep 13, 2016 |
|
| 221 | + * @return array |
|
| 222 | + */ |
|
| 223 | + public function getHeaders() { |
|
| 224 | 224 | |
| 225 | - return $this->headers; |
|
| 225 | + return $this->headers; |
|
| 226 | 226 | |
| 227 | - } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Set headers |
|
| 231 | - * @author Shima Payro <[email protected]> |
|
| 232 | - * @since Sep 13, 2016 |
|
| 233 | - * @return array |
|
| 234 | - */ |
|
| 235 | - public function setHeaders( $headers = [] ) { |
|
| 229 | + /** |
|
| 230 | + * Set headers |
|
| 231 | + * @author Shima Payro <[email protected]> |
|
| 232 | + * @since Sep 13, 2016 |
|
| 233 | + * @return array |
|
| 234 | + */ |
|
| 235 | + public function setHeaders( $headers = [] ) { |
|
| 236 | 236 | |
| 237 | - $this->headers = $headers; |
|
| 237 | + $this->headers = $headers; |
|
| 238 | 238 | |
| 239 | - return $this; |
|
| 239 | + return $this; |
|
| 240 | 240 | |
| 241 | - } |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Response which contains status and data |
|
| 245 | - * @param json $data |
|
| 246 | - * @author Shima Payro <[email protected]> |
|
| 247 | - * @since May 2, 2016 9:50:19 AM |
|
| 248 | - * @return json |
|
| 249 | - * @uses |
|
| 250 | - * @see |
|
| 251 | - */ |
|
| 252 | - public function respondWithResult( $data = NULL ) { |
|
| 243 | + /** |
|
| 244 | + * Response which contains status and data |
|
| 245 | + * @param json $data |
|
| 246 | + * @author Shima Payro <[email protected]> |
|
| 247 | + * @since May 2, 2016 9:50:19 AM |
|
| 248 | + * @return json |
|
| 249 | + * @uses |
|
| 250 | + * @see |
|
| 251 | + */ |
|
| 252 | + public function respondWithResult( $data = NULL ) { |
|
| 253 | 253 | |
| 254 | - $res[ 'status' ] = $this->getStatusText(); |
|
| 254 | + $res[ 'status' ] = $this->getStatusText(); |
|
| 255 | 255 | |
| 256 | - //if it's about laravel validation error |
|
| 257 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
| 256 | + //if it's about laravel validation error |
|
| 257 | + if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
| 258 | 258 | |
| 259 | - $res[ 'error' ] = $this->getErrorCode(); |
|
| 260 | - $res[ 'message' ] = $data; |
|
| 259 | + $res[ 'error' ] = $this->getErrorCode(); |
|
| 260 | + $res[ 'message' ] = $data; |
|
| 261 | 261 | |
| 262 | - } else { |
|
| 262 | + } else { |
|
| 263 | 263 | |
| 264 | - $res[ 'result' ] = $data; |
|
| 264 | + $res[ 'result' ] = $data; |
|
| 265 | 265 | |
| 266 | - } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - return $this->respond( $res ); |
|
| 268 | + return $this->respond( $res ); |
|
| 269 | 269 | |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | 272 | } |
@@ -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 | |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | |
| 133 | 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 | |
| 138 | 139 | return response()->json( $data, $this->getStatusCode() ) |
| 139 | 140 | ->withHeaders( $this->getHeaders() ); |
@@ -158,10 +159,11 @@ discard block |
||
| 158 | 159 | |
| 159 | 160 | $res[ 'error' ] = $this->getErrorCode(); |
| 160 | 161 | |
| 161 | - if ( is_null( $message ) ) |
|
| 162 | - $res[ 'message' ] = $this->getErrorMessage(); |
|
| 163 | - else |
|
| 164 | - $res[ 'message' ] = $message; |
|
| 162 | + if ( is_null( $message ) ) { |
|
| 163 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
| 164 | + } else { |
|
| 165 | + $res[ 'message' ] = $message; |
|
| 166 | + } |
|
| 165 | 167 | |
| 166 | 168 | } else { |
| 167 | 169 | |