@@ -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 | * Getter for $statusCode |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @uses |
| 59 | 59 | * @see |
| 60 | 60 | */ |
| 61 | - public function setStatusCode( $statusCode ) { |
|
| 61 | + public function setStatusCode($statusCode) { |
|
| 62 | 62 | |
| 63 | 63 | $this->statusCode = $statusCode; |
| 64 | 64 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @uses |
| 89 | 89 | * @see |
| 90 | 90 | */ |
| 91 | - public function setStatusText( $statusText ) { |
|
| 91 | + public function setStatusText($statusText) { |
|
| 92 | 92 | |
| 93 | 93 | $this->statusText = $statusText; |
| 94 | 94 | |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | * @uses |
| 106 | 106 | * @see |
| 107 | 107 | */ |
| 108 | - public function respond( $data ) { |
|
| 108 | + public function respond($data) { |
|
| 109 | 109 | |
| 110 | - $result = array_filter( $this->getHeaders() ); |
|
| 110 | + $result = array_filter($this->getHeaders()); |
|
| 111 | 111 | |
| 112 | - if ( empty( $result ) ) |
|
| 113 | - return response()->json( $data, $this->getStatusCode() ); |
|
| 112 | + if (empty($result)) |
|
| 113 | + return response()->json($data, $this->getStatusCode()); |
|
| 114 | 114 | |
| 115 | - return response()->json( $data, $this->getStatusCode() ) |
|
| 116 | - ->withHeaders( $this->getHeaders() ); |
|
| 115 | + return response()->json($data, $this->getStatusCode()) |
|
| 116 | + ->withHeaders($this->getHeaders()); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | * @uses |
| 127 | 127 | * @see |
| 128 | 128 | */ |
| 129 | - public function respondWithMessage( $message = NULL ) { |
|
| 129 | + public function respondWithMessage($message = NULL) { |
|
| 130 | 130 | |
| 131 | 131 | $res[ 'status' ] = $this->getStatusText(); |
| 132 | 132 | |
| 133 | 133 | //if it's about failure |
| 134 | - if ( $this->getErrorCode() ) { |
|
| 134 | + if ($this->getErrorCode()) { |
|
| 135 | 135 | |
| 136 | 136 | $res[ 'error' ] = $this->getErrorCode(); |
| 137 | 137 | $res[ 'message' ] = $this->getErrorMessage(); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return $this->respond( $res ); |
|
| 145 | + return $this->respond($res); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | * @param $errorCode integer |
| 154 | 154 | * @return instance |
| 155 | 155 | */ |
| 156 | - public function setErrorCode( $errorCode ) { |
|
| 156 | + public function setErrorCode($errorCode) { |
|
| 157 | 157 | |
| 158 | - $this->error = config( 'errors.' . $errorCode ); |
|
| 158 | + $this->error = config('errors.'.$errorCode); |
|
| 159 | 159 | |
| 160 | 160 | $this->errorCode = $errorCode; |
| 161 | 161 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function getErrorMessage() { |
| 185 | 185 | |
| 186 | - return $this->error['message']; |
|
| 186 | + return $this->error[ 'message' ]; |
|
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @since Sep 13, 2016 |
| 206 | 206 | * @return array |
| 207 | 207 | */ |
| 208 | - public function setHeaders( $headers = [] ) { |
|
| 208 | + public function setHeaders($headers = [ ]) { |
|
| 209 | 209 | |
| 210 | 210 | $this->headers = $headers; |
| 211 | 211 | |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | * @uses |
| 223 | 223 | * @see |
| 224 | 224 | */ |
| 225 | - public function respondWithResult( $data = NULL ) { |
|
| 225 | + public function respondWithResult($data = NULL) { |
|
| 226 | 226 | |
| 227 | 227 | $res[ 'status' ] = $this->getStatusText(); |
| 228 | 228 | |
| 229 | 229 | //if it's about laravel validation error |
| 230 | - if ( $this->getErrorCode() && $this->getStatusCode() == 420 ) { |
|
| 230 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
| 231 | 231 | |
| 232 | 232 | $res[ 'error' ] = $this->getErrorCode(); |
| 233 | 233 | $res[ 'message' ] = $data; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - return $this->respond( $res ); |
|
| 241 | + return $this->respond($res); |
|
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | |