@@ -7,11 +7,11 @@ |
||
| 7 | 7 | class Respond extends Facade { |
| 8 | 8 | |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Get the registered name of the component. |
|
| 12 | - * |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - protected static function getFacadeAccessor() { return 'Anetwork\Respond\Messages'; } |
|
| 10 | + /** |
|
| 11 | + * Get the registered name of the component. |
|
| 12 | + * |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + protected static function getFacadeAccessor() { return 'Anetwork\Respond\Messages'; } |
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -341,6 +341,10 @@ |
||
| 341 | 341 | return $file; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | + /** |
|
| 345 | + * @param string $class |
|
| 346 | + * @param string $ext |
|
| 347 | + */ |
|
| 344 | 348 | private function findFileWithExtension($class, $ext) |
| 345 | 349 | { |
| 346 | 350 | // PSR-4 lookup |
@@ -123,20 +123,20 @@ discard block |
||
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $first = $prefix[0]; |
|
| 127 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 128 | - $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
| 126 | + $first = $prefix[ 0 ]; |
|
| 127 | + if (!isset($this->prefixesPsr0[ $first ][ $prefix ])) { |
|
| 128 | + $this->prefixesPsr0[ $first ][ $prefix ] = (array) $paths; |
|
| 129 | 129 | |
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | if ($prepend) { |
| 133 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 133 | + $this->prefixesPsr0[ $first ][ $prefix ] = array_merge( |
|
| 134 | 134 | (array) $paths, |
| 135 | - $this->prefixesPsr0[$first][$prefix] |
|
| 135 | + $this->prefixesPsr0[ $first ][ $prefix ] |
|
| 136 | 136 | ); |
| 137 | 137 | } else { |
| 138 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 139 | - $this->prefixesPsr0[$first][$prefix], |
|
| 138 | + $this->prefixesPsr0[ $first ][ $prefix ] = array_merge( |
|
| 139 | + $this->prefixesPsr0[ $first ][ $prefix ], |
|
| 140 | 140 | (array) $paths |
| 141 | 141 | ); |
| 142 | 142 | } |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | (array) $paths |
| 168 | 168 | ); |
| 169 | 169 | } |
| 170 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 170 | + } elseif (!isset($this->prefixDirsPsr4[ $prefix ])) { |
|
| 171 | 171 | // Register directories for a new namespace. |
| 172 | 172 | $length = strlen($prefix); |
| 173 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 173 | + if ('\\' !== $prefix[ $length - 1 ]) { |
|
| 174 | 174 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 175 | 175 | } |
| 176 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 177 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 176 | + $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length; |
|
| 177 | + $this->prefixDirsPsr4[ $prefix ] = (array) $paths; |
|
| 178 | 178 | } elseif ($prepend) { |
| 179 | 179 | // Prepend directories for an already registered namespace. |
| 180 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 180 | + $this->prefixDirsPsr4[ $prefix ] = array_merge( |
|
| 181 | 181 | (array) $paths, |
| 182 | - $this->prefixDirsPsr4[$prefix] |
|
| 182 | + $this->prefixDirsPsr4[ $prefix ] |
|
| 183 | 183 | ); |
| 184 | 184 | } else { |
| 185 | 185 | // Append directories for an already registered namespace. |
| 186 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 187 | - $this->prefixDirsPsr4[$prefix], |
|
| 186 | + $this->prefixDirsPsr4[ $prefix ] = array_merge( |
|
| 187 | + $this->prefixDirsPsr4[ $prefix ], |
|
| 188 | 188 | (array) $paths |
| 189 | 189 | ); |
| 190 | 190 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | if (!$prefix) { |
| 203 | 203 | $this->fallbackDirsPsr0 = (array) $paths; |
| 204 | 204 | } else { |
| 205 | - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
| 205 | + $this->prefixesPsr0[ $prefix[ 0 ] ][ $prefix ] = (array) $paths; |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -221,11 +221,11 @@ discard block |
||
| 221 | 221 | $this->fallbackDirsPsr4 = (array) $paths; |
| 222 | 222 | } else { |
| 223 | 223 | $length = strlen($prefix); |
| 224 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 224 | + if ('\\' !== $prefix[ $length - 1 ]) { |
|
| 225 | 225 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 226 | 226 | } |
| 227 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 228 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 227 | + $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length; |
|
| 228 | + $this->prefixDirsPsr4[ $prefix ] = (array) $paths; |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
@@ -314,15 +314,15 @@ discard block |
||
| 314 | 314 | public function findFile($class) |
| 315 | 315 | { |
| 316 | 316 | // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 |
| 317 | - if ('\\' == $class[0]) { |
|
| 317 | + if ('\\' == $class[ 0 ]) { |
|
| 318 | 318 | $class = substr($class, 1); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // class map lookup |
| 322 | - if (isset($this->classMap[$class])) { |
|
| 323 | - return $this->classMap[$class]; |
|
| 322 | + if (isset($this->classMap[ $class ])) { |
|
| 323 | + return $this->classMap[ $class ]; |
|
| 324 | 324 | } |
| 325 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
| 325 | + if ($this->classMapAuthoritative || isset($this->missingClasses[ $class ])) { |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | if (false === $file) { |
| 337 | 337 | // Remember that this class does not exist. |
| 338 | - $this->missingClasses[$class] = true; |
|
| 338 | + $this->missingClasses[ $class ] = true; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | return $file; |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | private function findFileWithExtension($class, $ext) |
| 345 | 345 | { |
| 346 | 346 | // PSR-4 lookup |
| 347 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 347 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 348 | 348 | |
| 349 | - $first = $class[0]; |
|
| 350 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
| 351 | - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { |
|
| 349 | + $first = $class[ 0 ]; |
|
| 350 | + if (isset($this->prefixLengthsPsr4[ $first ])) { |
|
| 351 | + foreach ($this->prefixLengthsPsr4[ $first ] as $prefix => $length) { |
|
| 352 | 352 | if (0 === strpos($class, $prefix)) { |
| 353 | - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { |
|
| 354 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { |
|
| 353 | + foreach ($this->prefixDirsPsr4[ $prefix ] as $dir) { |
|
| 354 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $length))) { |
|
| 355 | 355 | return $file; |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | // PSR-4 fallback dirs |
| 363 | 363 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 364 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 364 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 365 | 365 | return $file; |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -373,14 +373,14 @@ discard block |
||
| 373 | 373 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 374 | 374 | } else { |
| 375 | 375 | // PEAR-like class name |
| 376 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 376 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if (isset($this->prefixesPsr0[$first])) { |
|
| 380 | - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
| 379 | + if (isset($this->prefixesPsr0[ $first ])) { |
|
| 380 | + foreach ($this->prefixesPsr0[ $first ] as $prefix => $dirs) { |
|
| 381 | 381 | if (0 === strpos($class, $prefix)) { |
| 382 | 382 | foreach ($dirs as $dir) { |
| 383 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 383 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 384 | 384 | return $file; |
| 385 | 385 | } |
| 386 | 386 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | // PSR-0 fallback dirs |
| 392 | 392 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 393 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 393 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 394 | 394 | return $file; |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -6,24 +6,24 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitb90bf1d271f3139658812a290f5c564b |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'A' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'Anetwork\\Respond\\' => 17, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'Anetwork\\Respond\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/../..' . '/src', |
|
| 20 | - 1 => __DIR__ . '/../..' . '/tests', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/../..'.'/src', |
|
| 20 | + 1 => __DIR__.'/../..'.'/tests', |
|
| 21 | 21 | ), |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | 24 | public static function getInitializer(ClassLoader $loader) |
| 25 | 25 | { |
| 26 | - return \Closure::bind(function () use ($loader) { |
|
| 26 | + return \Closure::bind(function() use ($loader) { |
|
| 27 | 27 | $loader->prefixLengthsPsr4 = ComposerStaticInitb90bf1d271f3139658812a290f5c564b::$prefixLengthsPsr4; |
| 28 | 28 | $loader->prefixDirsPsr4 = ComposerStaticInitb90bf1d271f3139658812a290f5c564b::$prefixDirsPsr4; |
| 29 | 29 | |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = dirname($vendorDir); |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'Anetwork\\Respond\\' => array($baseDir . '/src', $baseDir . '/tests'), |
|
| 9 | + 'Anetwork\\Respond\\' => array($baseDir.'/src', $baseDir.'/tests'), |
|
| 10 | 10 | ); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -25,21 +25,21 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); |
| 27 | 27 | if ($useStaticLoader) { |
| 28 | - require_once __DIR__ . '/autoload_static.php'; |
|
| 28 | + require_once __DIR__.'/autoload_static.php'; |
|
| 29 | 29 | |
| 30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitb90bf1d271f3139658812a290f5c564b::getInitializer($loader)); |
| 31 | 31 | } else { |
| 32 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
| 32 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
| 33 | 33 | foreach ($map as $namespace => $path) { |
| 34 | 34 | $loader->set($namespace, $path); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
| 37 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
| 38 | 38 | foreach ($map as $namespace => $path) { |
| 39 | 39 | $loader->setPsr4($namespace, $path); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
| 42 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
| 43 | 43 | if ($classMap) { |
| 44 | 44 | $loader->addClassMap($classMap); |
| 45 | 45 | } |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer' . '/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer'.'/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitb90bf1d271f3139658812a290f5c564b::getLoader(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * Setter for $statusCode |
| 54 | 54 | * @param integer $statusCode |
| 55 | - * @return App\Htpp\Responds\Respond |
|
| 55 | + * @return Main |
|
| 56 | 56 | * @author Shima Payro <[email protected]> |
| 57 | 57 | * @since May 2, 2016 9:47:04 AM |
| 58 | 58 | * @uses |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * Setter for $statusText |
| 84 | 84 | * @param String $statusText |
| 85 | - * @return App\HtppApp\Htpp\Responds\Respond |
|
| 85 | + * @return Main |
|
| 86 | 86 | * @author Shima Payro <[email protected]> |
| 87 | 87 | * @since May 2, 2016 9:48:23 AM |
| 88 | 88 | * @uses |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @author Mehdi Hosseini <[email protected]> |
| 152 | 152 | * @since August 24, 2016 |
| 153 | 153 | * @param $errorCode integer |
| 154 | - * @return instance |
|
| 154 | + * @return Main |
|
| 155 | 155 | */ |
| 156 | 156 | public function setErrorCode( $errorCode ) { |
| 157 | 157 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * Get headers |
| 204 | 204 | * @author Shima Payro <[email protected]> |
| 205 | 205 | * @since Sep 13, 2016 |
| 206 | - * @return array |
|
| 206 | + * @return Main |
|
| 207 | 207 | */ |
| 208 | 208 | public function setHeaders( $statusText = [] ) { |
| 209 | 209 | |
@@ -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 | |
@@ -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 array |
|
| 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 array |
|
| 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 = null ) { |
|
| 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 = null ) { |
|
| 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 = null ) { |
|
| 152 | + public function respondWithMessage($message = null) { |
|
| 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 | |
@@ -6,44 +6,44 @@ |
||
| 6 | 6 | |
| 7 | 7 | class RespondServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Perform post-registration booting of services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 9 | + /** |
|
| 10 | + * Perform post-registration booting of services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | 16 | |
| 17 | - $lang = \App::getLocale(); |
|
| 17 | + $lang = \App::getLocale(); |
|
| 18 | 18 | |
| 19 | - $this->publishes([ |
|
| 20 | - __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
| 21 | - ]); |
|
| 19 | + $this->publishes([ |
|
| 20 | + __DIR__.'/../errors/lang/' . $lang . '.php' => config_path( $lang . '.php' ), |
|
| 21 | + ]); |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Register any package services. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function register() |
|
| 32 | - { |
|
| 26 | + /** |
|
| 27 | + * Register any package services. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function register() |
|
| 32 | + { |
|
| 33 | 33 | |
| 34 | - $this->registerMessages(); |
|
| 34 | + $this->registerMessages(); |
|
| 35 | 35 | |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - private function registerMessages() |
|
| 39 | - { |
|
| 38 | + private function registerMessages() |
|
| 39 | + { |
|
| 40 | 40 | |
| 41 | - $this->app->bind( 'Anetwork\Respond\Messages', function() { |
|
| 41 | + $this->app->bind( 'Anetwork\Respond\Messages', function() { |
|
| 42 | 42 | |
| 43 | - return new Messages(); |
|
| 43 | + return new Messages(); |
|
| 44 | 44 | |
| 45 | - }); |
|
| 45 | + }); |
|
| 46 | 46 | |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
@@ -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 | |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function deleteSucceeded( $message = null ) { |
| 34 | 34 | |
| 35 | - if ( is_null( $message ) ) |
|
| 36 | - $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 35 | + if ( is_null( $message ) ) { |
|
| 36 | + $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | return $this->setStatusCode( 200 ) |
| 39 | 40 | ->setStatusText( 'success' ) |
@@ -51,8 +52,9 @@ discard block |
||
| 51 | 52 | */ |
| 52 | 53 | public function updateSucceeded( $message = null ) { |
| 53 | 54 | |
| 54 | - if ( is_null( $message ) ) |
|
| 55 | - $message = $this->config[ 'success' ][ 'update' ]; |
|
| 55 | + if ( is_null( $message ) ) { |
|
| 56 | + $message = $this->config[ 'success' ][ 'update' ]; |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | return $this->setStatusCode( 200 ) |
| 58 | 60 | ->setStatusText( 'success' ) |
@@ -70,8 +72,9 @@ discard block |
||
| 70 | 72 | */ |
| 71 | 73 | public function insertSucceeded( $message = null ) { |
| 72 | 74 | |
| 73 | - if ( is_null( $message ) ) |
|
| 74 | - $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 75 | + if ( is_null( $message ) ) { |
|
| 76 | + $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 77 | + } |
|
| 75 | 78 | |
| 76 | 79 | return $this->setStatusCode( 200 ) |
| 77 | 80 | ->setStatusText( 'success' ) |
@@ -89,8 +92,9 @@ discard block |
||
| 89 | 92 | */ |
| 90 | 93 | public function deleteFaild( $message = null ) { |
| 91 | 94 | |
| 92 | - if ( is_null( $message ) ) |
|
| 93 | - $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 95 | + if ( is_null( $message ) ) { |
|
| 96 | + $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 97 | + } |
|
| 94 | 98 | |
| 95 | 99 | return $this->setStatusCode( 447 ) |
| 96 | 100 | ->setStatusText( 'fail' ) |
@@ -109,8 +113,9 @@ discard block |
||
| 109 | 113 | */ |
| 110 | 114 | public function updateFaild( $message = null ) { |
| 111 | 115 | |
| 112 | - if ( is_null( $message ) ) |
|
| 113 | - $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 116 | + if ( is_null( $message ) ) { |
|
| 117 | + $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 118 | + } |
|
| 114 | 119 | |
| 115 | 120 | return $this->setStatusCode( 449 ) |
| 116 | 121 | ->setStatusText( 'fail' ) |
@@ -129,8 +134,9 @@ discard block |
||
| 129 | 134 | */ |
| 130 | 135 | public function insertFaild( $message = null ) { |
| 131 | 136 | |
| 132 | - if ( is_null( $message ) ) |
|
| 133 | - $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 137 | + if ( is_null( $message ) ) { |
|
| 138 | + $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 139 | + } |
|
| 134 | 140 | |
| 135 | 141 | return $this->setStatusCode( 448 ) |
| 136 | 142 | ->setStatusText( 'fail' ) |
@@ -142,7 +142,6 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * Database connection is refused |
| 144 | 144 | * @author Shima Payro <[email protected]> |
| 145 | - * @param String $message |
|
| 146 | 145 | * @since May 2, 2016 9:54:45 AM |
| 147 | 146 | * @uses |
| 148 | 147 | * @see |
@@ -159,7 +158,6 @@ discard block |
||
| 159 | 158 | /** |
| 160 | 159 | * page requested is not found |
| 161 | 160 | * @author Shima Payro <[email protected]> |
| 162 | - * @param String $message |
|
| 163 | 161 | * @since May 2, 2016 9:55:20 AM |
| 164 | 162 | * @uses |
| 165 | 163 | * @see |
@@ -176,7 +174,6 @@ discard block |
||
| 176 | 174 | /** |
| 177 | 175 | * Wrong parameters are entered |
| 178 | 176 | * @author Shima Payro <[email protected]> |
| 179 | - * @param String $message |
|
| 180 | 177 | * @since May 2, 2016 9:55:20 AM |
| 181 | 178 | * @uses |
| 182 | 179 | * @see |
@@ -193,7 +190,6 @@ discard block |
||
| 193 | 190 | /** |
| 194 | 191 | * Method is not allowed |
| 195 | 192 | * @author Shima Payro <[email protected]> |
| 196 | - * @param String $message |
|
| 197 | 193 | * @since May 2, 2016 9:55:20 AM |
| 198 | 194 | * @uses |
| 199 | 195 | * @see |
@@ -210,7 +206,6 @@ discard block |
||
| 210 | 206 | /** |
| 211 | 207 | * There ara validation errors |
| 212 | 208 | * @author Shima Payro <[email protected]> |
| 213 | - * @param Array $data |
|
| 214 | 209 | * @since May 2, 2016 9:55:20 AM |
| 215 | 210 | * @uses |
| 216 | 211 | * @see |
@@ -227,7 +222,6 @@ discard block |
||
| 227 | 222 | /** |
| 228 | 223 | * The request field is not found |
| 229 | 224 | * @author Shima Payro <[email protected]> |
| 230 | - * @param String $message |
|
| 231 | 225 | * @since May 2, 2016 9:55:20 AM |
| 232 | 226 | * @uses |
| 233 | 227 | * @see |
@@ -6,271 +6,271 @@ |
||
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Request succeeded and contains json result |
|
| 11 | - * @param array $data |
|
| 12 | - * @author Shima Payro <[email protected]> |
|
| 13 | - * @since May 2, 2016 9:50:51 AM |
|
| 14 | - * @uses |
|
| 15 | - * @see |
|
| 16 | - */ |
|
| 17 | - public function succeed( $data ) { |
|
| 18 | - |
|
| 19 | - return $this->setStatusCode( 200 ) |
|
| 20 | - ->setStatusText( 'success' ) |
|
| 21 | - ->respondWithResult( $data ); |
|
| 22 | - |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Delete action is succeed |
|
| 27 | - * @author Shima Payro <[email protected]> |
|
| 28 | - * @param String $message |
|
| 29 | - * @since May 2, 2016 9:52:05 AM |
|
| 30 | - * @uses |
|
| 31 | - * @see |
|
| 32 | - */ |
|
| 33 | - public function deleteSucceeded( $message = null ) { |
|
| 34 | - |
|
| 35 | - if ( is_null( $message ) ) |
|
| 36 | - $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 37 | - |
|
| 38 | - return $this->setStatusCode( 200 ) |
|
| 39 | - ->setStatusText( 'success' ) |
|
| 40 | - ->respondWithMessage( $message ); |
|
| 41 | - |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Update action is succeed |
|
| 46 | - * @author Shima Payro <[email protected]> |
|
| 47 | - * @param String $message |
|
| 48 | - * @since May 2, 2016 9:52:52 AM |
|
| 49 | - * @uses |
|
| 50 | - * @see |
|
| 51 | - */ |
|
| 52 | - public function updateSucceeded( $message = null ) { |
|
| 53 | - |
|
| 54 | - if ( is_null( $message ) ) |
|
| 55 | - $message = $this->config[ 'success' ][ 'update' ]; |
|
| 56 | - |
|
| 57 | - return $this->setStatusCode( 200 ) |
|
| 58 | - ->setStatusText( 'success' ) |
|
| 59 | - ->respondWithMessage( $message ); |
|
| 60 | - |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Insert action is succeed |
|
| 65 | - * @author Shima Payro <[email protected]> |
|
| 66 | - * @param String $message |
|
| 67 | - * @since May 2, 2016 9:53:26 AM |
|
| 68 | - * @uses |
|
| 69 | - * @see |
|
| 70 | - */ |
|
| 71 | - public function insertSucceeded( $message = null ) { |
|
| 72 | - |
|
| 73 | - if ( is_null( $message ) ) |
|
| 74 | - $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 75 | - |
|
| 76 | - return $this->setStatusCode( 200 ) |
|
| 77 | - ->setStatusText( 'success' ) |
|
| 78 | - ->respondWithMessage( $message ); |
|
| 79 | - |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Delete action is faild |
|
| 84 | - * @author Shima Payro <[email protected]> |
|
| 85 | - * @param String $message |
|
| 86 | - * @since May 2, 2016 9:53:53 AM |
|
| 87 | - * @uses |
|
| 88 | - * @see |
|
| 89 | - */ |
|
| 90 | - public function deleteFaild( $message = null ) { |
|
| 91 | - |
|
| 92 | - if ( is_null( $message ) ) |
|
| 93 | - $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 94 | - |
|
| 95 | - return $this->setStatusCode( 447 ) |
|
| 96 | - ->setStatusText( 'fail' ) |
|
| 97 | - ->setErrorCode( 5447 ) |
|
| 98 | - ->respondWithMessage( $message ); |
|
| 99 | - |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Update action is succeed |
|
| 104 | - * @author Shima Payro <[email protected]> |
|
| 105 | - * @param String $message |
|
| 106 | - * @since May 2, 2016 9:54:09 AM |
|
| 107 | - * @uses |
|
| 108 | - * @see |
|
| 109 | - */ |
|
| 110 | - public function updateFaild( $message = null ) { |
|
| 111 | - |
|
| 112 | - if ( is_null( $message ) ) |
|
| 113 | - $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 114 | - |
|
| 115 | - return $this->setStatusCode( 449 ) |
|
| 116 | - ->setStatusText( 'fail' ) |
|
| 117 | - ->setErrorCode( 5449 ) |
|
| 118 | - ->respondWithMessage( $message ); |
|
| 119 | - |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Insert action is faild |
|
| 124 | - * @author Shima Payro <[email protected]> |
|
| 125 | - * @param String $message |
|
| 126 | - * @since May 2, 2016 9:54:27 AM |
|
| 127 | - * @uses |
|
| 128 | - * @see |
|
| 129 | - */ |
|
| 130 | - public function insertFaild( $message = null ) { |
|
| 131 | - |
|
| 132 | - if ( is_null( $message ) ) |
|
| 133 | - $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 134 | - |
|
| 135 | - return $this->setStatusCode( 448 ) |
|
| 136 | - ->setStatusText( 'fail' ) |
|
| 137 | - ->setErrorCode( 5448 ) |
|
| 138 | - ->respondWithMessage( $message ); |
|
| 139 | - |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Database connection is refused |
|
| 144 | - * @author Shima Payro <[email protected]> |
|
| 145 | - * @param String $message |
|
| 146 | - * @since May 2, 2016 9:54:45 AM |
|
| 147 | - * @uses |
|
| 148 | - * @see |
|
| 149 | - */ |
|
| 150 | - public function connectionRefused() { |
|
| 151 | - |
|
| 152 | - return $this->setStatusCode( 445 ) |
|
| 153 | - ->setStatusText( 'fail' ) |
|
| 154 | - ->setErrorCode( 5445 ) |
|
| 155 | - ->respondWithMessage(); |
|
| 156 | - |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * page requested is not found |
|
| 161 | - * @author Shima Payro <[email protected]> |
|
| 162 | - * @param String $message |
|
| 163 | - * @since May 2, 2016 9:55:20 AM |
|
| 164 | - * @uses |
|
| 165 | - * @see |
|
| 166 | - */ |
|
| 167 | - public function notFound() { |
|
| 168 | - |
|
| 169 | - return $this->setStatusCode( 404 ) |
|
| 170 | - ->setStatusText( 'fail' ) |
|
| 171 | - ->setErrorCode( 5404 ) |
|
| 172 | - ->respondWithMessage(); |
|
| 173 | - |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Wrong parameters are entered |
|
| 178 | - * @author Shima Payro <[email protected]> |
|
| 179 | - * @param String $message |
|
| 180 | - * @since May 2, 2016 9:55:20 AM |
|
| 181 | - * @uses |
|
| 182 | - * @see |
|
| 183 | - */ |
|
| 184 | - public function wrongParameters() { |
|
| 185 | - |
|
| 186 | - return $this->setStatusCode( 406 ) |
|
| 187 | - ->setStatusText( 'fail' ) |
|
| 188 | - ->setErrorCode( 5406 ) |
|
| 189 | - ->respondWithMessage(); |
|
| 190 | - |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Method is not allowed |
|
| 195 | - * @author Shima Payro <[email protected]> |
|
| 196 | - * @param String $message |
|
| 197 | - * @since May 2, 2016 9:55:20 AM |
|
| 198 | - * @uses |
|
| 199 | - * @see |
|
| 200 | - */ |
|
| 201 | - public function methodNotAllowed() { |
|
| 202 | - |
|
| 203 | - return $this->setStatusCode( 405 ) |
|
| 204 | - ->setStatusText( 'fail' ) |
|
| 205 | - ->setErrorCode( 5405 ) |
|
| 206 | - ->respondWithMessage(); |
|
| 207 | - |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * There ara validation errors |
|
| 212 | - * @author Shima Payro <[email protected]> |
|
| 213 | - * @param Array $data |
|
| 214 | - * @since May 2, 2016 9:55:20 AM |
|
| 215 | - * @uses |
|
| 216 | - * @see |
|
| 217 | - */ |
|
| 218 | - public function validationErrors( $message = null ) { |
|
| 219 | - |
|
| 220 | - return $this->setStatusCode( 420 ) |
|
| 221 | - ->setStatusText( 'fail' ) |
|
| 222 | - ->setErrorCode( 5420 ) |
|
| 223 | - ->respondWithResult( $message ); |
|
| 224 | - |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * The request field is not found |
|
| 229 | - * @author Shima Payro <[email protected]> |
|
| 230 | - * @param String $message |
|
| 231 | - * @since May 2, 2016 9:55:20 AM |
|
| 232 | - * @uses |
|
| 233 | - * @see |
|
| 234 | - */ |
|
| 235 | - public function requestFieldNotFound() { |
|
| 236 | - |
|
| 237 | - return $this->setStatusCode( 446 ) |
|
| 238 | - ->setStatusText( 'fail' ) |
|
| 239 | - ->setErrorCode( 1001 ) |
|
| 240 | - ->respondWithMessage(); |
|
| 241 | - |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * The request field is doublicated |
|
| 246 | - * @author Mehdi Hosseini <[email protected]> |
|
| 247 | - * @since August 24, 2016 |
|
| 248 | - * @return json |
|
| 249 | - */ |
|
| 250 | - public function requestFieldDuplicated() { |
|
| 251 | - |
|
| 252 | - return $this->setStatusCode( 400 ) |
|
| 253 | - ->setStatusText( 'fail' ) |
|
| 254 | - ->SetErrorCode(1004) |
|
| 255 | - ->respondWithMessage(); |
|
| 256 | - |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * Custom error message according to error config file |
|
| 261 | - * @author Mehdi Hosseini <[email protected]> |
|
| 262 | - * @since August 24, 2016 |
|
| 263 | - * @param $code integer |
|
| 264 | - * @return json |
|
| 265 | - */ |
|
| 266 | - public function error( $code ) { |
|
| 267 | - |
|
| 268 | - return $this->SetStatusCode( 400 ) |
|
| 269 | - ->setStatusText( 'fail' ) |
|
| 270 | - ->setErrorCode( $code ) |
|
| 271 | - ->respondWithMessage(); |
|
| 272 | - |
|
| 273 | - } |
|
| 9 | + /** |
|
| 10 | + * Request succeeded and contains json result |
|
| 11 | + * @param array $data |
|
| 12 | + * @author Shima Payro <[email protected]> |
|
| 13 | + * @since May 2, 2016 9:50:51 AM |
|
| 14 | + * @uses |
|
| 15 | + * @see |
|
| 16 | + */ |
|
| 17 | + public function succeed( $data ) { |
|
| 18 | + |
|
| 19 | + return $this->setStatusCode( 200 ) |
|
| 20 | + ->setStatusText( 'success' ) |
|
| 21 | + ->respondWithResult( $data ); |
|
| 22 | + |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Delete action is succeed |
|
| 27 | + * @author Shima Payro <[email protected]> |
|
| 28 | + * @param String $message |
|
| 29 | + * @since May 2, 2016 9:52:05 AM |
|
| 30 | + * @uses |
|
| 31 | + * @see |
|
| 32 | + */ |
|
| 33 | + public function deleteSucceeded( $message = null ) { |
|
| 34 | + |
|
| 35 | + if ( is_null( $message ) ) |
|
| 36 | + $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 37 | + |
|
| 38 | + return $this->setStatusCode( 200 ) |
|
| 39 | + ->setStatusText( 'success' ) |
|
| 40 | + ->respondWithMessage( $message ); |
|
| 41 | + |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Update action is succeed |
|
| 46 | + * @author Shima Payro <[email protected]> |
|
| 47 | + * @param String $message |
|
| 48 | + * @since May 2, 2016 9:52:52 AM |
|
| 49 | + * @uses |
|
| 50 | + * @see |
|
| 51 | + */ |
|
| 52 | + public function updateSucceeded( $message = null ) { |
|
| 53 | + |
|
| 54 | + if ( is_null( $message ) ) |
|
| 55 | + $message = $this->config[ 'success' ][ 'update' ]; |
|
| 56 | + |
|
| 57 | + return $this->setStatusCode( 200 ) |
|
| 58 | + ->setStatusText( 'success' ) |
|
| 59 | + ->respondWithMessage( $message ); |
|
| 60 | + |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Insert action is succeed |
|
| 65 | + * @author Shima Payro <[email protected]> |
|
| 66 | + * @param String $message |
|
| 67 | + * @since May 2, 2016 9:53:26 AM |
|
| 68 | + * @uses |
|
| 69 | + * @see |
|
| 70 | + */ |
|
| 71 | + public function insertSucceeded( $message = null ) { |
|
| 72 | + |
|
| 73 | + if ( is_null( $message ) ) |
|
| 74 | + $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 75 | + |
|
| 76 | + return $this->setStatusCode( 200 ) |
|
| 77 | + ->setStatusText( 'success' ) |
|
| 78 | + ->respondWithMessage( $message ); |
|
| 79 | + |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Delete action is faild |
|
| 84 | + * @author Shima Payro <[email protected]> |
|
| 85 | + * @param String $message |
|
| 86 | + * @since May 2, 2016 9:53:53 AM |
|
| 87 | + * @uses |
|
| 88 | + * @see |
|
| 89 | + */ |
|
| 90 | + public function deleteFaild( $message = null ) { |
|
| 91 | + |
|
| 92 | + if ( is_null( $message ) ) |
|
| 93 | + $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 94 | + |
|
| 95 | + return $this->setStatusCode( 447 ) |
|
| 96 | + ->setStatusText( 'fail' ) |
|
| 97 | + ->setErrorCode( 5447 ) |
|
| 98 | + ->respondWithMessage( $message ); |
|
| 99 | + |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Update action is succeed |
|
| 104 | + * @author Shima Payro <[email protected]> |
|
| 105 | + * @param String $message |
|
| 106 | + * @since May 2, 2016 9:54:09 AM |
|
| 107 | + * @uses |
|
| 108 | + * @see |
|
| 109 | + */ |
|
| 110 | + public function updateFaild( $message = null ) { |
|
| 111 | + |
|
| 112 | + if ( is_null( $message ) ) |
|
| 113 | + $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 114 | + |
|
| 115 | + return $this->setStatusCode( 449 ) |
|
| 116 | + ->setStatusText( 'fail' ) |
|
| 117 | + ->setErrorCode( 5449 ) |
|
| 118 | + ->respondWithMessage( $message ); |
|
| 119 | + |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Insert action is faild |
|
| 124 | + * @author Shima Payro <[email protected]> |
|
| 125 | + * @param String $message |
|
| 126 | + * @since May 2, 2016 9:54:27 AM |
|
| 127 | + * @uses |
|
| 128 | + * @see |
|
| 129 | + */ |
|
| 130 | + public function insertFaild( $message = null ) { |
|
| 131 | + |
|
| 132 | + if ( is_null( $message ) ) |
|
| 133 | + $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 134 | + |
|
| 135 | + return $this->setStatusCode( 448 ) |
|
| 136 | + ->setStatusText( 'fail' ) |
|
| 137 | + ->setErrorCode( 5448 ) |
|
| 138 | + ->respondWithMessage( $message ); |
|
| 139 | + |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Database connection is refused |
|
| 144 | + * @author Shima Payro <[email protected]> |
|
| 145 | + * @param String $message |
|
| 146 | + * @since May 2, 2016 9:54:45 AM |
|
| 147 | + * @uses |
|
| 148 | + * @see |
|
| 149 | + */ |
|
| 150 | + public function connectionRefused() { |
|
| 151 | + |
|
| 152 | + return $this->setStatusCode( 445 ) |
|
| 153 | + ->setStatusText( 'fail' ) |
|
| 154 | + ->setErrorCode( 5445 ) |
|
| 155 | + ->respondWithMessage(); |
|
| 156 | + |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * page requested is not found |
|
| 161 | + * @author Shima Payro <[email protected]> |
|
| 162 | + * @param String $message |
|
| 163 | + * @since May 2, 2016 9:55:20 AM |
|
| 164 | + * @uses |
|
| 165 | + * @see |
|
| 166 | + */ |
|
| 167 | + public function notFound() { |
|
| 168 | + |
|
| 169 | + return $this->setStatusCode( 404 ) |
|
| 170 | + ->setStatusText( 'fail' ) |
|
| 171 | + ->setErrorCode( 5404 ) |
|
| 172 | + ->respondWithMessage(); |
|
| 173 | + |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Wrong parameters are entered |
|
| 178 | + * @author Shima Payro <[email protected]> |
|
| 179 | + * @param String $message |
|
| 180 | + * @since May 2, 2016 9:55:20 AM |
|
| 181 | + * @uses |
|
| 182 | + * @see |
|
| 183 | + */ |
|
| 184 | + public function wrongParameters() { |
|
| 185 | + |
|
| 186 | + return $this->setStatusCode( 406 ) |
|
| 187 | + ->setStatusText( 'fail' ) |
|
| 188 | + ->setErrorCode( 5406 ) |
|
| 189 | + ->respondWithMessage(); |
|
| 190 | + |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Method is not allowed |
|
| 195 | + * @author Shima Payro <[email protected]> |
|
| 196 | + * @param String $message |
|
| 197 | + * @since May 2, 2016 9:55:20 AM |
|
| 198 | + * @uses |
|
| 199 | + * @see |
|
| 200 | + */ |
|
| 201 | + public function methodNotAllowed() { |
|
| 202 | + |
|
| 203 | + return $this->setStatusCode( 405 ) |
|
| 204 | + ->setStatusText( 'fail' ) |
|
| 205 | + ->setErrorCode( 5405 ) |
|
| 206 | + ->respondWithMessage(); |
|
| 207 | + |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * There ara validation errors |
|
| 212 | + * @author Shima Payro <[email protected]> |
|
| 213 | + * @param Array $data |
|
| 214 | + * @since May 2, 2016 9:55:20 AM |
|
| 215 | + * @uses |
|
| 216 | + * @see |
|
| 217 | + */ |
|
| 218 | + public function validationErrors( $message = null ) { |
|
| 219 | + |
|
| 220 | + return $this->setStatusCode( 420 ) |
|
| 221 | + ->setStatusText( 'fail' ) |
|
| 222 | + ->setErrorCode( 5420 ) |
|
| 223 | + ->respondWithResult( $message ); |
|
| 224 | + |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * The request field is not found |
|
| 229 | + * @author Shima Payro <[email protected]> |
|
| 230 | + * @param String $message |
|
| 231 | + * @since May 2, 2016 9:55:20 AM |
|
| 232 | + * @uses |
|
| 233 | + * @see |
|
| 234 | + */ |
|
| 235 | + public function requestFieldNotFound() { |
|
| 236 | + |
|
| 237 | + return $this->setStatusCode( 446 ) |
|
| 238 | + ->setStatusText( 'fail' ) |
|
| 239 | + ->setErrorCode( 1001 ) |
|
| 240 | + ->respondWithMessage(); |
|
| 241 | + |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * The request field is doublicated |
|
| 246 | + * @author Mehdi Hosseini <[email protected]> |
|
| 247 | + * @since August 24, 2016 |
|
| 248 | + * @return json |
|
| 249 | + */ |
|
| 250 | + public function requestFieldDuplicated() { |
|
| 251 | + |
|
| 252 | + return $this->setStatusCode( 400 ) |
|
| 253 | + ->setStatusText( 'fail' ) |
|
| 254 | + ->SetErrorCode(1004) |
|
| 255 | + ->respondWithMessage(); |
|
| 256 | + |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * Custom error message according to error config file |
|
| 261 | + * @author Mehdi Hosseini <[email protected]> |
|
| 262 | + * @since August 24, 2016 |
|
| 263 | + * @param $code integer |
|
| 264 | + * @return json |
|
| 265 | + */ |
|
| 266 | + public function error( $code ) { |
|
| 267 | + |
|
| 268 | + return $this->SetStatusCode( 400 ) |
|
| 269 | + ->setStatusText( 'fail' ) |
|
| 270 | + ->setErrorCode( $code ) |
|
| 271 | + ->respondWithMessage(); |
|
| 272 | + |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | 276 | } |
@@ -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 = null ) { |
|
| 33 | + public function deleteSucceeded($message = null) { |
|
| 34 | 34 | |
| 35 | - if ( is_null( $message ) ) |
|
| 35 | + if (is_null($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 = null ) { |
|
| 52 | + public function updateSucceeded($message = null) { |
|
| 53 | 53 | |
| 54 | - if ( is_null( $message ) ) |
|
| 54 | + if (is_null($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 = null ) { |
|
| 71 | + public function insertSucceeded($message = null) { |
|
| 72 | 72 | |
| 73 | - if ( is_null( $message ) ) |
|
| 73 | + if (is_null($message)) |
|
| 74 | 74 | $message = $this->config[ 'success' ][ 'insert' ]; |
| 75 | 75 | |
| 76 | - return $this->setStatusCode( 200 ) |
|
| 77 | - ->setStatusText( 'success' ) |
|
| 78 | - ->respondWithMessage( $message ); |
|
| 76 | + return $this->setStatusCode(200) |
|
| 77 | + ->setStatusText('success') |
|
| 78 | + ->respondWithMessage($message); |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | * @uses |
| 88 | 88 | * @see |
| 89 | 89 | */ |
| 90 | - public function deleteFaild( $message = null ) { |
|
| 90 | + public function deleteFaild($message = null) { |
|
| 91 | 91 | |
| 92 | - if ( is_null( $message ) ) |
|
| 92 | + if (is_null($message)) |
|
| 93 | 93 | $message = $this->config[ 'fail' ][ 'delete' ]; |
| 94 | 94 | |
| 95 | - return $this->setStatusCode( 447 ) |
|
| 96 | - ->setStatusText( 'fail' ) |
|
| 97 | - ->setErrorCode( 5447 ) |
|
| 98 | - ->respondWithMessage( $message ); |
|
| 95 | + return $this->setStatusCode(447) |
|
| 96 | + ->setStatusText('fail') |
|
| 97 | + ->setErrorCode(5447) |
|
| 98 | + ->respondWithMessage($message); |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | * @uses |
| 108 | 108 | * @see |
| 109 | 109 | */ |
| 110 | - public function updateFaild( $message = null ) { |
|
| 110 | + public function updateFaild($message = null) { |
|
| 111 | 111 | |
| 112 | - if ( is_null( $message ) ) |
|
| 112 | + if (is_null($message)) |
|
| 113 | 113 | $message = $this->config[ 'fail' ][ 'update' ]; |
| 114 | 114 | |
| 115 | - return $this->setStatusCode( 449 ) |
|
| 116 | - ->setStatusText( 'fail' ) |
|
| 117 | - ->setErrorCode( 5449 ) |
|
| 118 | - ->respondWithMessage( $message ); |
|
| 115 | + return $this->setStatusCode(449) |
|
| 116 | + ->setStatusText('fail') |
|
| 117 | + ->setErrorCode(5449) |
|
| 118 | + ->respondWithMessage($message); |
|
| 119 | 119 | |
| 120 | 120 | } |
| 121 | 121 | |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | * @uses |
| 128 | 128 | * @see |
| 129 | 129 | */ |
| 130 | - public function insertFaild( $message = null ) { |
|
| 130 | + public function insertFaild($message = null) { |
|
| 131 | 131 | |
| 132 | - if ( is_null( $message ) ) |
|
| 132 | + if (is_null($message)) |
|
| 133 | 133 | $message = $this->config[ 'fail' ][ 'insert' ]; |
| 134 | 134 | |
| 135 | - return $this->setStatusCode( 448 ) |
|
| 136 | - ->setStatusText( 'fail' ) |
|
| 137 | - ->setErrorCode( 5448 ) |
|
| 138 | - ->respondWithMessage( $message ); |
|
| 135 | + return $this->setStatusCode(448) |
|
| 136 | + ->setStatusText('fail') |
|
| 137 | + ->setErrorCode(5448) |
|
| 138 | + ->respondWithMessage($message); |
|
| 139 | 139 | |
| 140 | 140 | } |
| 141 | 141 | |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function connectionRefused() { |
| 151 | 151 | |
| 152 | - return $this->setStatusCode( 445 ) |
|
| 153 | - ->setStatusText( 'fail' ) |
|
| 154 | - ->setErrorCode( 5445 ) |
|
| 152 | + return $this->setStatusCode(445) |
|
| 153 | + ->setStatusText('fail') |
|
| 154 | + ->setErrorCode(5445) |
|
| 155 | 155 | ->respondWithMessage(); |
| 156 | 156 | |
| 157 | 157 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function notFound() { |
| 168 | 168 | |
| 169 | - return $this->setStatusCode( 404 ) |
|
| 170 | - ->setStatusText( 'fail' ) |
|
| 171 | - ->setErrorCode( 5404 ) |
|
| 169 | + return $this->setStatusCode(404) |
|
| 170 | + ->setStatusText('fail') |
|
| 171 | + ->setErrorCode(5404) |
|
| 172 | 172 | ->respondWithMessage(); |
| 173 | 173 | |
| 174 | 174 | } |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function wrongParameters() { |
| 185 | 185 | |
| 186 | - return $this->setStatusCode( 406 ) |
|
| 187 | - ->setStatusText( 'fail' ) |
|
| 188 | - ->setErrorCode( 5406 ) |
|
| 186 | + return $this->setStatusCode(406) |
|
| 187 | + ->setStatusText('fail') |
|
| 188 | + ->setErrorCode(5406) |
|
| 189 | 189 | ->respondWithMessage(); |
| 190 | 190 | |
| 191 | 191 | } |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function methodNotAllowed() { |
| 202 | 202 | |
| 203 | - return $this->setStatusCode( 405 ) |
|
| 204 | - ->setStatusText( 'fail' ) |
|
| 205 | - ->setErrorCode( 5405 ) |
|
| 203 | + return $this->setStatusCode(405) |
|
| 204 | + ->setStatusText('fail') |
|
| 205 | + ->setErrorCode(5405) |
|
| 206 | 206 | ->respondWithMessage(); |
| 207 | 207 | |
| 208 | 208 | } |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @uses |
| 216 | 216 | * @see |
| 217 | 217 | */ |
| 218 | - public function validationErrors( $message = null ) { |
|
| 218 | + public function validationErrors($message = null) { |
|
| 219 | 219 | |
| 220 | - return $this->setStatusCode( 420 ) |
|
| 221 | - ->setStatusText( 'fail' ) |
|
| 222 | - ->setErrorCode( 5420 ) |
|
| 223 | - ->respondWithResult( $message ); |
|
| 220 | + return $this->setStatusCode(420) |
|
| 221 | + ->setStatusText('fail') |
|
| 222 | + ->setErrorCode(5420) |
|
| 223 | + ->respondWithResult($message); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function requestFieldNotFound() { |
| 236 | 236 | |
| 237 | - return $this->setStatusCode( 446 ) |
|
| 238 | - ->setStatusText( 'fail' ) |
|
| 239 | - ->setErrorCode( 1001 ) |
|
| 237 | + return $this->setStatusCode(446) |
|
| 238 | + ->setStatusText('fail') |
|
| 239 | + ->setErrorCode(1001) |
|
| 240 | 240 | ->respondWithMessage(); |
| 241 | 241 | |
| 242 | 242 | } |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function requestFieldDuplicated() { |
| 251 | 251 | |
| 252 | - return $this->setStatusCode( 400 ) |
|
| 253 | - ->setStatusText( 'fail' ) |
|
| 252 | + return $this->setStatusCode(400) |
|
| 253 | + ->setStatusText('fail') |
|
| 254 | 254 | ->SetErrorCode(1004) |
| 255 | 255 | ->respondWithMessage(); |
| 256 | 256 | |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | * @param $code integer |
| 264 | 264 | * @return json |
| 265 | 265 | */ |
| 266 | - public function error( $code ) { |
|
| 266 | + public function error($code) { |
|
| 267 | 267 | |
| 268 | - return $this->SetStatusCode( 400 ) |
|
| 269 | - ->setStatusText( 'fail' ) |
|
| 270 | - ->setErrorCode( $code ) |
|
| 268 | + return $this->SetStatusCode(400) |
|
| 269 | + ->setStatusText('fail') |
|
| 270 | + ->setErrorCode($code) |
|
| 271 | 271 | ->respondWithMessage(); |
| 272 | 272 | |
| 273 | 273 | } |