@@ -13,8 +13,8 @@ |
||
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | 15 | protected static function getFacadeAccessor() |
| 16 | - { |
|
| 17 | - return 'Vahid\Respond\Messages'; |
|
| 18 | - } |
|
| 16 | + { |
|
| 17 | + return 'Vahid\Respond\Messages'; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | 20 | } |
@@ -5,15 +5,15 @@ discard block |
||
| 5 | 5 | class Messages extends Main |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Request succeeded and contains json result |
|
| 10 | - * @param array $data |
|
| 11 | - * @return mixed |
|
| 12 | - * @since May 2, 2016 9:50:51 AM |
|
| 13 | - * @uses |
|
| 14 | - * @see |
|
| 15 | - * @author Shima Payro <[email protected]> |
|
| 16 | - */ |
|
| 8 | + /** |
|
| 9 | + * Request succeeded and contains json result |
|
| 10 | + * @param array $data |
|
| 11 | + * @return mixed |
|
| 12 | + * @since May 2, 2016 9:50:51 AM |
|
| 13 | + * @uses |
|
| 14 | + * @see |
|
| 15 | + * @author Shima Payro <[email protected]> |
|
| 16 | + */ |
|
| 17 | 17 | public function succeed( $data ) { |
| 18 | 18 | |
| 19 | 19 | return $this->setStatusCode( 200 ) |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Delete action is succeed |
|
| 27 | - * @param String $message |
|
| 28 | - * @return mixed |
|
| 29 | - * @since May 2, 2016 9:52:05 AM |
|
| 30 | - * @uses |
|
| 31 | - * @see |
|
| 32 | - * @author Shima Payro <[email protected]> |
|
| 33 | - */ |
|
| 25 | + /** |
|
| 26 | + * Delete action is succeed |
|
| 27 | + * @param String $message |
|
| 28 | + * @return mixed |
|
| 29 | + * @since May 2, 2016 9:52:05 AM |
|
| 30 | + * @uses |
|
| 31 | + * @see |
|
| 32 | + * @author Shima Payro <[email protected]> |
|
| 33 | + */ |
|
| 34 | 34 | public function deleteSucceeded( $message = null ) { |
| 35 | 35 | |
| 36 | 36 | if ( is_null( $message ) ) |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Update action is succeed |
|
| 47 | - * @param String $message |
|
| 48 | - * @return mixed |
|
| 49 | - * @since May 2, 2016 9:52:52 AM |
|
| 50 | - * @uses |
|
| 51 | - * @see |
|
| 52 | - * @author Shima Payro <[email protected]> |
|
| 53 | - */ |
|
| 45 | + /** |
|
| 46 | + * Update action is succeed |
|
| 47 | + * @param String $message |
|
| 48 | + * @return mixed |
|
| 49 | + * @since May 2, 2016 9:52:52 AM |
|
| 50 | + * @uses |
|
| 51 | + * @see |
|
| 52 | + * @author Shima Payro <[email protected]> |
|
| 53 | + */ |
|
| 54 | 54 | public function updateSucceeded( $message = null ) { |
| 55 | 55 | |
| 56 | 56 | if ( is_null( $message ) ) |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Insert action is succeed |
|
| 67 | - * @param String $message |
|
| 68 | - * @return mixed |
|
| 69 | - * @since May 2, 2016 9:53:26 AM |
|
| 70 | - * @uses |
|
| 71 | - * @see |
|
| 72 | - * @author Shima Payro <[email protected]> |
|
| 73 | - */ |
|
| 65 | + /** |
|
| 66 | + * Insert action is succeed |
|
| 67 | + * @param String $message |
|
| 68 | + * @return mixed |
|
| 69 | + * @since May 2, 2016 9:53:26 AM |
|
| 70 | + * @uses |
|
| 71 | + * @see |
|
| 72 | + * @author Shima Payro <[email protected]> |
|
| 73 | + */ |
|
| 74 | 74 | public function insertSucceeded( $message = null ) { |
| 75 | 75 | |
| 76 | 76 | if ( is_null( $message ) ) |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Delete action is faild |
|
| 87 | - * @param String $message |
|
| 88 | - * @return mixed |
|
| 89 | - * @since May 2, 2016 9:53:53 AM |
|
| 90 | - * @uses |
|
| 91 | - * @see |
|
| 92 | - * @author Shima Payro <[email protected]> |
|
| 93 | - */ |
|
| 85 | + /** |
|
| 86 | + * Delete action is faild |
|
| 87 | + * @param String $message |
|
| 88 | + * @return mixed |
|
| 89 | + * @since May 2, 2016 9:53:53 AM |
|
| 90 | + * @uses |
|
| 91 | + * @see |
|
| 92 | + * @author Shima Payro <[email protected]> |
|
| 93 | + */ |
|
| 94 | 94 | public function deleteFaild( $message = null ) { |
| 95 | 95 | |
| 96 | 96 | if ( is_null( $message ) ) |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Update action is succeed |
|
| 108 | - * @param String $message |
|
| 109 | - * @return mixed |
|
| 110 | - * @since May 2, 2016 9:54:09 AM |
|
| 111 | - * @uses |
|
| 112 | - * @see |
|
| 113 | - * @author Shima Payro <[email protected]> |
|
| 114 | - */ |
|
| 106 | + /** |
|
| 107 | + * Update action is succeed |
|
| 108 | + * @param String $message |
|
| 109 | + * @return mixed |
|
| 110 | + * @since May 2, 2016 9:54:09 AM |
|
| 111 | + * @uses |
|
| 112 | + * @see |
|
| 113 | + * @author Shima Payro <[email protected]> |
|
| 114 | + */ |
|
| 115 | 115 | public function updateFaild( $message = null ) { |
| 116 | 116 | |
| 117 | 117 | if ( is_null( $message ) ) |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Insert action is faild |
|
| 129 | - * @param String $message |
|
| 130 | - * @return mixed |
|
| 131 | - * @since May 2, 2016 9:54:27 AM |
|
| 132 | - * @uses |
|
| 133 | - * @see |
|
| 134 | - * @author Shima Payro <[email protected]> |
|
| 135 | - */ |
|
| 127 | + /** |
|
| 128 | + * Insert action is faild |
|
| 129 | + * @param String $message |
|
| 130 | + * @return mixed |
|
| 131 | + * @since May 2, 2016 9:54:27 AM |
|
| 132 | + * @uses |
|
| 133 | + * @see |
|
| 134 | + * @author Shima Payro <[email protected]> |
|
| 135 | + */ |
|
| 136 | 136 | public function insertFaild( $message = null ) { |
| 137 | 137 | |
| 138 | 138 | if ( is_null( $message ) ) |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Database connection is refused |
|
| 150 | - * @return mixed |
|
| 151 | - * @since May 2, 2016 9:54:45 AM |
|
| 152 | - * @uses |
|
| 153 | - * @see |
|
| 154 | - * @author Shima Payro <[email protected]> |
|
| 155 | - */ |
|
| 148 | + /** |
|
| 149 | + * Database connection is refused |
|
| 150 | + * @return mixed |
|
| 151 | + * @since May 2, 2016 9:54:45 AM |
|
| 152 | + * @uses |
|
| 153 | + * @see |
|
| 154 | + * @author Shima Payro <[email protected]> |
|
| 155 | + */ |
|
| 156 | 156 | public function connectionRefused() { |
| 157 | 157 | |
| 158 | 158 | return $this->setStatusCode( 445 ) |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * page requested is not found |
|
| 167 | - * @param String $message |
|
| 168 | - * @return mixed |
|
| 169 | - * @since May 2, 2016 9:55:20 AM |
|
| 170 | - * @uses |
|
| 171 | - * @see |
|
| 172 | - * @author Shima Payro <[email protected]> |
|
| 173 | - */ |
|
| 165 | + /** |
|
| 166 | + * page requested is not found |
|
| 167 | + * @param String $message |
|
| 168 | + * @return mixed |
|
| 169 | + * @since May 2, 2016 9:55:20 AM |
|
| 170 | + * @uses |
|
| 171 | + * @see |
|
| 172 | + * @author Shima Payro <[email protected]> |
|
| 173 | + */ |
|
| 174 | 174 | public function notFound() { |
| 175 | 175 | |
| 176 | 176 | return $this->setStatusCode( 404 ) |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Wrong parameters are entered |
|
| 185 | - * @param String $message |
|
| 186 | - * @return mixed |
|
| 187 | - * @since May 2, 2016 9:55:20 AM |
|
| 188 | - * @uses |
|
| 189 | - * @see |
|
| 190 | - * @author Shima Payro <[email protected]> |
|
| 191 | - */ |
|
| 183 | + /** |
|
| 184 | + * Wrong parameters are entered |
|
| 185 | + * @param String $message |
|
| 186 | + * @return mixed |
|
| 187 | + * @since May 2, 2016 9:55:20 AM |
|
| 188 | + * @uses |
|
| 189 | + * @see |
|
| 190 | + * @author Shima Payro <[email protected]> |
|
| 191 | + */ |
|
| 192 | 192 | public function wrongParameters() { |
| 193 | 193 | |
| 194 | 194 | return $this->setStatusCode( 406 ) |
@@ -198,15 +198,15 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Method is not allowed |
|
| 203 | - * @param String $message |
|
| 204 | - * @return mixed |
|
| 205 | - * @since May 2, 2016 9:55:20 AM |
|
| 206 | - * @uses |
|
| 207 | - * @see |
|
| 208 | - * @author Shima Payro <[email protected]> |
|
| 209 | - */ |
|
| 201 | + /** |
|
| 202 | + * Method is not allowed |
|
| 203 | + * @param String $message |
|
| 204 | + * @return mixed |
|
| 205 | + * @since May 2, 2016 9:55:20 AM |
|
| 206 | + * @uses |
|
| 207 | + * @see |
|
| 208 | + * @author Shima Payro <[email protected]> |
|
| 209 | + */ |
|
| 210 | 210 | public function methodNotAllowed() { |
| 211 | 211 | |
| 212 | 212 | return $this->setStatusCode( 405 ) |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * There ara validation errors |
|
| 221 | - * @param $data array |
|
| 222 | - * @return mixed |
|
| 223 | - * @since May 2, 2016 9:55:20 AM |
|
| 224 | - * @uses |
|
| 225 | - * @see |
|
| 226 | - * @author Shima Payro <[email protected]> |
|
| 227 | - */ |
|
| 219 | + /** |
|
| 220 | + * There ara validation errors |
|
| 221 | + * @param $data array |
|
| 222 | + * @return mixed |
|
| 223 | + * @since May 2, 2016 9:55:20 AM |
|
| 224 | + * @uses |
|
| 225 | + * @see |
|
| 226 | + * @author Shima Payro <[email protected]> |
|
| 227 | + */ |
|
| 228 | 228 | public function validationErrors( $message = null ) { |
| 229 | 229 | |
| 230 | 230 | return $this->setStatusCode( 420 ) |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * The request field is not found |
|
| 239 | - * @param String $message |
|
| 240 | - * @return mixed |
|
| 241 | - * @since May 2, 2016 9:55:20 AM |
|
| 242 | - * @uses |
|
| 243 | - * @see |
|
| 244 | - * @author Shima Payro <[email protected]> |
|
| 245 | - */ |
|
| 237 | + /** |
|
| 238 | + * The request field is not found |
|
| 239 | + * @param String $message |
|
| 240 | + * @return mixed |
|
| 241 | + * @since May 2, 2016 9:55:20 AM |
|
| 242 | + * @uses |
|
| 243 | + * @see |
|
| 244 | + * @author Shima Payro <[email protected]> |
|
| 245 | + */ |
|
| 246 | 246 | public function requestFieldNotFound() { |
| 247 | 247 | |
| 248 | 248 | return $this->setStatusCode( 446 ) |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | * @see |
| 15 | 15 | * @author Shima Payro <[email protected]> |
| 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 | |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | * @see |
| 32 | 32 | * @author Shima Payro <[email protected]> |
| 33 | 33 | */ |
| 34 | - public function deleteSucceeded( $message = null ) { |
|
| 34 | + public function deleteSucceeded($message = null) { |
|
| 35 | 35 | |
| 36 | - if ( is_null( $message ) ) |
|
| 36 | + if (is_null($message)) |
|
| 37 | 37 | $message = $this->config[ 'success' ][ 'delete' ]; |
| 38 | 38 | |
| 39 | - return $this->setStatusCode( 200 ) |
|
| 40 | - ->setStatusText( 'success' ) |
|
| 41 | - ->respondWithMessage( $message ); |
|
| 39 | + return $this->setStatusCode(200) |
|
| 40 | + ->setStatusText('success') |
|
| 41 | + ->respondWithMessage($message); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | * @see |
| 52 | 52 | * @author Shima Payro <[email protected]> |
| 53 | 53 | */ |
| 54 | - public function updateSucceeded( $message = null ) { |
|
| 54 | + public function updateSucceeded($message = null) { |
|
| 55 | 55 | |
| 56 | - if ( is_null( $message ) ) |
|
| 56 | + if (is_null($message)) |
|
| 57 | 57 | $message = $this->config[ 'success' ][ 'update' ]; |
| 58 | 58 | |
| 59 | - return $this->setStatusCode( 200 ) |
|
| 60 | - ->setStatusText( 'success' ) |
|
| 61 | - ->respondWithMessage( $message ); |
|
| 59 | + return $this->setStatusCode(200) |
|
| 60 | + ->setStatusText('success') |
|
| 61 | + ->respondWithMessage($message); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | * @see |
| 72 | 72 | * @author Shima Payro <[email protected]> |
| 73 | 73 | */ |
| 74 | - public function insertSucceeded( $message = null ) { |
|
| 74 | + public function insertSucceeded($message = null) { |
|
| 75 | 75 | |
| 76 | - if ( is_null( $message ) ) |
|
| 76 | + if (is_null($message)) |
|
| 77 | 77 | $message = $this->config[ 'success' ][ 'insert' ]; |
| 78 | 78 | |
| 79 | - return $this->setStatusCode( 200 ) |
|
| 80 | - ->setStatusText( 'success' ) |
|
| 81 | - ->respondWithMessage( $message ); |
|
| 79 | + return $this->setStatusCode(200) |
|
| 80 | + ->setStatusText('success') |
|
| 81 | + ->respondWithMessage($message); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | * @see |
| 92 | 92 | * @author Shima Payro <[email protected]> |
| 93 | 93 | */ |
| 94 | - public function deleteFaild( $message = null ) { |
|
| 94 | + public function deleteFaild($message = null) { |
|
| 95 | 95 | |
| 96 | - if ( is_null( $message ) ) |
|
| 96 | + if (is_null($message)) |
|
| 97 | 97 | $message = $this->config[ 'fail' ][ 'delete' ]; |
| 98 | 98 | |
| 99 | - return $this->setStatusCode( 447 ) |
|
| 100 | - ->setStatusText( 'fail' ) |
|
| 101 | - ->setErrorCode( 5447 ) |
|
| 102 | - ->respondWithMessage( $message ); |
|
| 99 | + return $this->setStatusCode(447) |
|
| 100 | + ->setStatusText('fail') |
|
| 101 | + ->setErrorCode(5447) |
|
| 102 | + ->respondWithMessage($message); |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | * @see |
| 113 | 113 | * @author Shima Payro <[email protected]> |
| 114 | 114 | */ |
| 115 | - public function updateFaild( $message = null ) { |
|
| 115 | + public function updateFaild($message = null) { |
|
| 116 | 116 | |
| 117 | - if ( is_null( $message ) ) |
|
| 117 | + if (is_null($message)) |
|
| 118 | 118 | $message = $this->config[ 'fail' ][ 'update' ]; |
| 119 | 119 | |
| 120 | - return $this->setStatusCode( 449 ) |
|
| 121 | - ->setStatusText( 'fail' ) |
|
| 122 | - ->setErrorCode( 5449 ) |
|
| 123 | - ->respondWithMessage( $message ); |
|
| 120 | + return $this->setStatusCode(449) |
|
| 121 | + ->setStatusText('fail') |
|
| 122 | + ->setErrorCode(5449) |
|
| 123 | + ->respondWithMessage($message); |
|
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
@@ -133,15 +133,15 @@ discard block |
||
| 133 | 133 | * @see |
| 134 | 134 | * @author Shima Payro <[email protected]> |
| 135 | 135 | */ |
| 136 | - public function insertFaild( $message = null ) { |
|
| 136 | + public function insertFaild($message = null) { |
|
| 137 | 137 | |
| 138 | - if ( is_null( $message ) ) |
|
| 138 | + if (is_null($message)) |
|
| 139 | 139 | $message = $this->config[ 'fail' ][ 'insert' ]; |
| 140 | 140 | |
| 141 | - return $this->setStatusCode( 448 ) |
|
| 142 | - ->setStatusText( 'fail' ) |
|
| 143 | - ->setErrorCode( 5448 ) |
|
| 144 | - ->respondWithMessage( $message ); |
|
| 141 | + return $this->setStatusCode(448) |
|
| 142 | + ->setStatusText('fail') |
|
| 143 | + ->setErrorCode(5448) |
|
| 144 | + ->respondWithMessage($message); |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function connectionRefused() { |
| 157 | 157 | |
| 158 | - return $this->setStatusCode( 445 ) |
|
| 159 | - ->setStatusText( 'fail' ) |
|
| 160 | - ->setErrorCode( 5445 ) |
|
| 158 | + return $this->setStatusCode(445) |
|
| 159 | + ->setStatusText('fail') |
|
| 160 | + ->setErrorCode(5445) |
|
| 161 | 161 | ->respondWithMessage(); |
| 162 | 162 | |
| 163 | 163 | } |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function notFound() { |
| 175 | 175 | |
| 176 | - return $this->setStatusCode( 404 ) |
|
| 177 | - ->setStatusText( 'fail' ) |
|
| 178 | - ->setErrorCode( 5404 ) |
|
| 176 | + return $this->setStatusCode(404) |
|
| 177 | + ->setStatusText('fail') |
|
| 178 | + ->setErrorCode(5404) |
|
| 179 | 179 | ->respondWithMessage(); |
| 180 | 180 | |
| 181 | 181 | } |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function wrongParameters() { |
| 193 | 193 | |
| 194 | - return $this->setStatusCode( 406 ) |
|
| 195 | - ->setStatusText( 'fail' ) |
|
| 196 | - ->setErrorCode( 5406 ) |
|
| 194 | + return $this->setStatusCode(406) |
|
| 195 | + ->setStatusText('fail') |
|
| 196 | + ->setErrorCode(5406) |
|
| 197 | 197 | ->respondWithMessage(); |
| 198 | 198 | |
| 199 | 199 | } |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function methodNotAllowed() { |
| 211 | 211 | |
| 212 | - return $this->setStatusCode( 405 ) |
|
| 213 | - ->setStatusText( 'fail' ) |
|
| 214 | - ->setErrorCode( 5405 ) |
|
| 212 | + return $this->setStatusCode(405) |
|
| 213 | + ->setStatusText('fail') |
|
| 214 | + ->setErrorCode(5405) |
|
| 215 | 215 | ->respondWithMessage(); |
| 216 | 216 | |
| 217 | 217 | } |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | * @see |
| 226 | 226 | * @author Shima Payro <[email protected]> |
| 227 | 227 | */ |
| 228 | - public function validationErrors( $message = null ) { |
|
| 228 | + public function validationErrors($message = null) { |
|
| 229 | 229 | |
| 230 | - return $this->setStatusCode( 420 ) |
|
| 231 | - ->setStatusText( 'fail' ) |
|
| 232 | - ->setErrorCode( 5420 ) |
|
| 233 | - ->respondWithResult( $message ); |
|
| 230 | + return $this->setStatusCode(420) |
|
| 231 | + ->setStatusText('fail') |
|
| 232 | + ->setErrorCode(5420) |
|
| 233 | + ->respondWithResult($message); |
|
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function requestFieldNotFound() { |
| 247 | 247 | |
| 248 | - return $this->setStatusCode( 446 ) |
|
| 249 | - ->setStatusText( 'fail' ) |
|
| 250 | - ->setErrorCode( 1001 ) |
|
| 248 | + return $this->setStatusCode(446) |
|
| 249 | + ->setStatusText('fail') |
|
| 250 | + ->setErrorCode(1001) |
|
| 251 | 251 | ->respondWithMessage(); |
| 252 | 252 | |
| 253 | 253 | } |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function requestFieldDuplicated() { |
| 262 | 262 | |
| 263 | - return $this->setStatusCode( 400 ) |
|
| 264 | - ->setStatusText( 'fail' ) |
|
| 263 | + return $this->setStatusCode(400) |
|
| 264 | + ->setStatusText('fail') |
|
| 265 | 265 | ->SetErrorCode(1004) |
| 266 | 266 | ->respondWithMessage(); |
| 267 | 267 | |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | * @param $code integer |
| 275 | 275 | * @return mixed |
| 276 | 276 | */ |
| 277 | - public function error( $code ) { |
|
| 277 | + public function error($code) { |
|
| 278 | 278 | |
| 279 | - return $this->setStatusCode( 400 ) |
|
| 280 | - ->setStatusText( 'fail' ) |
|
| 281 | - ->setErrorCode( $code ) |
|
| 279 | + return $this->setStatusCode(400) |
|
| 280 | + ->setStatusText('fail') |
|
| 281 | + ->setErrorCode($code) |
|
| 282 | 282 | ->respondWithMessage(); |
| 283 | 283 | |
| 284 | 284 | } |
@@ -33,8 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function deleteSucceeded( $message = null ) { |
| 35 | 35 | |
| 36 | - if ( is_null( $message ) ) |
|
| 37 | - $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 36 | + if ( is_null( $message ) ) { |
|
| 37 | + $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | return $this->setStatusCode( 200 ) |
| 40 | 41 | ->setStatusText( 'success' ) |
@@ -53,8 +54,9 @@ discard block |
||
| 53 | 54 | */ |
| 54 | 55 | public function updateSucceeded( $message = null ) { |
| 55 | 56 | |
| 56 | - if ( is_null( $message ) ) |
|
| 57 | - $message = $this->config[ 'success' ][ 'update' ]; |
|
| 57 | + if ( is_null( $message ) ) { |
|
| 58 | + $message = $this->config[ 'success' ][ 'update' ]; |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | 61 | return $this->setStatusCode( 200 ) |
| 60 | 62 | ->setStatusText( 'success' ) |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | */ |
| 74 | 76 | public function insertSucceeded( $message = null ) { |
| 75 | 77 | |
| 76 | - if ( is_null( $message ) ) |
|
| 77 | - $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 78 | + if ( is_null( $message ) ) { |
|
| 79 | + $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | 82 | return $this->setStatusCode( 200 ) |
| 80 | 83 | ->setStatusText( 'success' ) |
@@ -93,8 +96,9 @@ discard block |
||
| 93 | 96 | */ |
| 94 | 97 | public function deleteFaild( $message = null ) { |
| 95 | 98 | |
| 96 | - if ( is_null( $message ) ) |
|
| 97 | - $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 99 | + if ( is_null( $message ) ) { |
|
| 100 | + $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 101 | + } |
|
| 98 | 102 | |
| 99 | 103 | return $this->setStatusCode( 447 ) |
| 100 | 104 | ->setStatusText( 'fail' ) |
@@ -114,8 +118,9 @@ discard block |
||
| 114 | 118 | */ |
| 115 | 119 | public function updateFaild( $message = null ) { |
| 116 | 120 | |
| 117 | - if ( is_null( $message ) ) |
|
| 118 | - $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 121 | + if ( is_null( $message ) ) { |
|
| 122 | + $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 123 | + } |
|
| 119 | 124 | |
| 120 | 125 | return $this->setStatusCode( 449 ) |
| 121 | 126 | ->setStatusText( 'fail' ) |
@@ -135,8 +140,9 @@ discard block |
||
| 135 | 140 | */ |
| 136 | 141 | public function insertFaild( $message = null ) { |
| 137 | 142 | |
| 138 | - if ( is_null( $message ) ) |
|
| 139 | - $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 143 | + if ( is_null( $message ) ) { |
|
| 144 | + $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 145 | + } |
|
| 140 | 146 | |
| 141 | 147 | return $this->setStatusCode( 448 ) |
| 142 | 148 | ->setStatusText( 'fail' ) |
@@ -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 | |