@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function __construct($app) |
| 17 | 17 | {
|
| 18 | - $this->app=$app; |
|
| 18 | + $this->app = $app; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function json() |
| 25 | 25 | {
|
| 26 | - $this->app->response='json'; |
|
| 26 | + $this->app->response = 'json'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,6 +31,6 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function xml() |
| 33 | 33 | {
|
| 34 | - $this->app->response='xml'; |
|
| 34 | + $this->app->response = 'xml'; |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | // if we leave the request process to the application side, |
| 59 | 59 | // then in this case we refer to the requestClient object in |
| 60 | 60 | // the services section of the store directory. |
| 61 | - (property_exists($this,'app') && $this->app) ? parent::handle() : $this->handle(); |
|
| 61 | + (property_exists($this, 'app') && $this->app) ? parent::handle() : $this->handle(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function autoValidate($validate) |
| 70 | 70 | {
|
| 71 | - foreach ($this->{$validate} as $object=>$datas){
|
|
| 72 | - if(Utils::isNamespaceExists($object)){
|
|
| 71 | + foreach ($this->{$validate} as $object=>$datas) {
|
|
| 72 | + if (Utils::isNamespaceExists($object)) {
|
|
| 73 | 73 | $getObjectInstance = app()->resolve($object); |
| 74 | - foreach ($datas as $dataKey=>$data){
|
|
| 75 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
|
|
| 76 | - if(isset($this->origin[$data])){
|
|
| 77 | - if(!is_array($this->origin[$data])){
|
|
| 74 | + foreach ($datas as $dataKey=>$data) {
|
|
| 75 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
|
|
| 76 | + if (isset($this->origin[$data])) {
|
|
| 77 | + if (!is_array($this->origin[$data])) {
|
|
| 78 | 78 | $this->origin[$data] = array($this->origin[$data]); |
| 79 | 79 | } |
| 80 | - foreach ($this->origin[$data] as $originData){
|
|
| 80 | + foreach ($this->origin[$data] as $originData) {
|
|
| 81 | 81 | $getObjectInstance->{$data}($originData);
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | // Determines which HTTP method |
| 101 | 101 | // the request object will be exposed to. |
| 102 | - if($this->checkProperties('http')){
|
|
| 102 | + if ($this->checkProperties('http')) {
|
|
| 103 | 103 | |
| 104 | 104 | // if the current http method does not exist |
| 105 | 105 | // in the http object, the exception will be thrown. |
| 106 | - if(!in_array($method,$this->http)){
|
|
| 106 | + if (!in_array($method, $this->http)) {
|
|
| 107 | 107 | |
| 108 | 108 | //exception batMethodCall |
| 109 | 109 | exception()->badMethodCall( |
| 110 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
|
|
| 110 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
|
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | {
|
| 123 | 123 | // from the properties of the object properties to |
| 124 | 124 | // the existing variables, control the array and at least one element. |
| 125 | - return (property_exists($this,$properties) |
|
| 125 | + return (property_exists($this, $properties) |
|
| 126 | 126 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
|
| 127 | 127 | } |
| 128 | 128 | |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | public function except($except) |
| 136 | 136 | {
|
| 137 | 137 | // the except parameter is a callable value. |
| 138 | - if(is_callable($except)){
|
|
| 139 | - $call = call_user_func_array($except,[$this]); |
|
| 138 | + if (is_callable($except)) {
|
|
| 139 | + $call = call_user_func_array($except, [$this]); |
|
| 140 | 140 | $except = $call; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // except with the except exceptions property |
| 144 | 144 | // and then assigning them to the inputs property. |
| 145 | - $this->except = array_merge($this->except,$except); |
|
| 146 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
| 145 | + $this->except = array_merge($this->except, $except); |
|
| 146 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
| 147 | 147 | |
| 148 | 148 | return $this; |
| 149 | 149 | } |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | {
|
| 158 | 158 | // expected method is executed. |
| 159 | 159 | // this method is a must for http method values to be found in this property. |
| 160 | - if($this->checkProperties('expected')){
|
|
| 160 | + if ($this->checkProperties('expected')) {
|
|
| 161 | 161 | |
| 162 | 162 | // if the expected values are not found in the inputs array, |
| 163 | 163 | // the exception will be thrown. |
| 164 | - foreach ($this->expected as $expected){
|
|
| 165 | - if(!isset($this->inputs[$expected])){
|
|
| 164 | + foreach ($this->expected as $expected) {
|
|
| 165 | + if (!isset($this->inputs[$expected])) {
|
|
| 166 | 166 | exception()->unexpectedValue('You absolutely have to send the value '.$expected.' for request object');
|
| 167 | 167 | } |
| 168 | 168 | } |
@@ -178,17 +178,17 @@ discard block |
||
| 178 | 178 | {
|
| 179 | 179 | // check the presence of the generator object |
| 180 | 180 | // and operate the generator over this object. |
| 181 | - if($this->checkProperties('auto_generators')){
|
|
| 181 | + if ($this->checkProperties('auto_generators')) {
|
|
| 182 | 182 | $generators = $this->auto_generators; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // check the presence of the generator object |
| 186 | 186 | // and operate the generator over this object. |
| 187 | - if($this->checkProperties('generators')){
|
|
| 188 | - $generators = array_merge(isset($generators) ? $generators: [],$this->generators); |
|
| 187 | + if ($this->checkProperties('generators')) {
|
|
| 188 | + $generators = array_merge(isset($generators) ? $generators : [], $this->generators); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if(isset($generators)){
|
|
| 191 | + if (isset($generators)) {
|
|
| 192 | 192 | $this->generatorMethod($generators); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -201,30 +201,30 @@ discard block |
||
| 201 | 201 | private function generatorMethod($generators) |
| 202 | 202 | {
|
| 203 | 203 | //generator array object |
| 204 | - foreach ($generators as $generator){
|
|
| 204 | + foreach ($generators as $generator) {
|
|
| 205 | 205 | |
| 206 | 206 | //generator method name |
| 207 | 207 | $generatorMethodName = $generator.'Generator'; |
| 208 | 208 | |
| 209 | 209 | // if the generator method is present, |
| 210 | 210 | // the fake value is assigned. |
| 211 | - if(method_exists($this,$generatorMethodName)){
|
|
| 211 | + if (method_exists($this, $generatorMethodName)) {
|
|
| 212 | 212 | |
| 213 | 213 | //fake registration |
| 214 | - if(!isset($this->inputs[$generator])){
|
|
| 214 | + if (!isset($this->inputs[$generator])) {
|
|
| 215 | 215 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 216 | 216 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 217 | 217 | } |
| 218 | 218 | else {
|
| 219 | 219 | |
| 220 | - if($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 221 | - && in_array($generator,$this->auto_generators_dont_overwrite)){
|
|
| 220 | + if ($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 221 | + && in_array($generator, $this->auto_generators_dont_overwrite)) {
|
|
| 222 | 222 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 223 | 223 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if($this->checkProperties('generators_dont_overwrite')
|
|
| 227 | - && in_array($generator,$this->generators_dont_overwrite)){
|
|
| 226 | + if ($this->checkProperties('generators_dont_overwrite')
|
|
| 227 | + && in_array($generator, $this->generators_dont_overwrite)) {
|
|
| 228 | 228 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 229 | 229 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 230 | 230 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | private function getClientObjects() |
| 255 | 255 | {
|
| 256 | - return array_diff_key($this->getObjects(),['inputs'=>[]]); |
|
| 256 | + return array_diff_key($this->getObjects(), ['inputs'=>[]]); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | {
|
| 297 | 297 | // we use the http method to write |
| 298 | 298 | // the values to the inputs and origin properties. |
| 299 | - foreach($this->requestHttp->resolve() as $key=>$value){
|
|
| 299 | + foreach ($this->requestHttp->resolve() as $key=>$value) {
|
|
| 300 | 300 | |
| 301 | 301 | //inputs and origin properties |
| 302 | 302 | $this->inputs[$key] = $value; |
@@ -312,68 +312,68 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @throws \ReflectionException |
| 314 | 314 | */ |
| 315 | - private function checkAnnotations($method,$key) |
|
| 315 | + private function checkAnnotations($method, $key) |
|
| 316 | 316 | {
|
| 317 | 317 | $reflection = $this->reflection->reflectionMethodParams($method); |
| 318 | 318 | $annotation = $reflection->document; |
| 319 | 319 | |
| 320 | 320 | $exceptionParamList = []; |
| 321 | 321 | |
| 322 | - if(preg_match('@exception\((.*?)\)\r\n@is',$annotation,$exception)){
|
|
| 322 | + if (preg_match('@exception\((.*?)\)\r\n@is', $annotation, $exception)) {
|
|
| 323 | 323 | |
| 324 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 325 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 326 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 324 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 325 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 326 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 327 | 327 | $exceptionParamList[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if(isset($exceptionParamList[$key]['params'])){
|
|
| 331 | - $paramsCommaExplode = explode(",",$exceptionParamList[$key]['params']);
|
|
| 330 | + if (isset($exceptionParamList[$key]['params'])) {
|
|
| 331 | + $paramsCommaExplode = explode(",", $exceptionParamList[$key]['params']);
|
|
| 332 | 332 | unset($exceptionParamList[$key]['params']); |
| 333 | - foreach ($paramsCommaExplode as $params){
|
|
| 334 | - $paramsEqualExplode = explode("=",$params);
|
|
| 335 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 333 | + foreach ($paramsCommaExplode as $params) {
|
|
| 334 | + $paramsEqualExplode = explode("=", $params);
|
|
| 335 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 336 | 336 | $exceptionParamList[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if(preg_match('@remove\((.*?)\)\r\n@is',$annotation,$remove)){
|
|
| 343 | - if(isset($this->inputs[$key])){
|
|
| 344 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 342 | + if (preg_match('@remove\((.*?)\)\r\n@is', $annotation, $remove)) {
|
|
| 343 | + if (isset($this->inputs[$key])) {
|
|
| 344 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 345 | 345 | unset($this->inputs[$key]); |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if(preg_match('@regex\((.*?)\)\r\n@is',$annotation,$regex)){
|
|
| 351 | - if(isset($this->inputs[$key])){
|
|
| 350 | + if (preg_match('@regex\((.*?)\)\r\n@is', $annotation, $regex)) {
|
|
| 351 | + if (isset($this->inputs[$key])) {
|
|
| 352 | 352 | |
| 353 | - if(is_array($this->inputs[$key])){
|
|
| 353 | + if (is_array($this->inputs[$key])) {
|
|
| 354 | 354 | |
| 355 | - foreach ($this->inputs[$key] as $inputKey=>$inputValue){
|
|
| 355 | + foreach ($this->inputs[$key] as $inputKey=>$inputValue) {
|
|
| 356 | 356 | |
| 357 | - if(!preg_match('@'.$regex[1].'@is',$inputValue)){
|
|
| 358 | - if(isset($exceptionParamList[$key])){
|
|
| 357 | + if (!preg_match('@'.$regex[1].'@is', $inputValue)) {
|
|
| 358 | + if (isset($exceptionParamList[$key])) {
|
|
| 359 | 359 | $keyParams = ($exceptionParamList[$key]['params']) ?? []; |
| 360 | - exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
|
| 360 | + exception($exceptionParamList[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
|
| 361 | 361 | } |
| 362 | - else{
|
|
| 362 | + else {
|
|
| 363 | 363 | exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | } |
| 369 | - else{
|
|
| 369 | + else {
|
|
| 370 | 370 | |
| 371 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 372 | - if(isset($exceptionParamList[$key])){
|
|
| 371 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 372 | + if (isset($exceptionParamList[$key])) {
|
|
| 373 | 373 | $keyParams = ($exceptionParamList[$key]['params']) ?? []; |
| 374 | - exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
|
| 374 | + exception($exceptionParamList[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
|
| 375 | 375 | } |
| 376 | - else{
|
|
| 376 | + else {
|
|
| 377 | 377 | exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 378 | 378 | } |
| 379 | 379 | } |
@@ -419,9 +419,9 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | // we update the input values after |
| 421 | 421 | // we receive and check the saved objects. |
| 422 | - foreach ($clientObjects as $key=>$value){
|
|
| 422 | + foreach ($clientObjects as $key=>$value) {
|
|
| 423 | 423 | |
| 424 | - if(isset($clientObjects['origin'][$key])){
|
|
| 424 | + if (isset($clientObjects['origin'][$key])) {
|
|
| 425 | 425 | |
| 426 | 426 | $this->{$key} = $clientObjects['origin'][$key];
|
| 427 | 427 | $this->inputs[$key] = $this->{$key};
|
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | // the request update to be performed using |
| 448 | 448 | // the method name to be used with the http method. |
| 449 | - $this->setRequestInputs($requestMethod,$key); |
|
| 449 | + $this->setRequestInputs($requestMethod, $key); |
|
| 450 | 450 | |
| 451 | 451 | // the request update to be performed using |
| 452 | 452 | // the method name to be used without the http method. |
| 453 | - $this->setRequestInputs($key,$key); |
|
| 453 | + $this->setRequestInputs($key, $key); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -459,27 +459,27 @@ discard block |
||
| 459 | 459 | * @param $method |
| 460 | 460 | * @param $key |
| 461 | 461 | */ |
| 462 | - private function setRequestInputs($method,$key) |
|
| 462 | + private function setRequestInputs($method, $key) |
|
| 463 | 463 | {
|
| 464 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
|
|
| 464 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
|
|
| 465 | 465 | |
| 466 | 466 | //check annotations for method |
| 467 | - $this->checkAnnotations($method,$key); |
|
| 467 | + $this->checkAnnotations($method, $key); |
|
| 468 | 468 | |
| 469 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
|
|
| 469 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
|
|
| 470 | 470 | |
| 471 | 471 | $inputKeys = $this->inputs[$key]; |
| 472 | 472 | |
| 473 | 473 | $this->inputs[$key] = []; |
| 474 | - foreach ($inputKeys as $input){
|
|
| 474 | + foreach ($inputKeys as $input) {
|
|
| 475 | 475 | |
| 476 | 476 | $this->{$key} = $input;
|
| 477 | 477 | $keyMethod = $this->{$method}();
|
| 478 | 478 | $this->inputs[$key][] = $keyMethod; |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | - else{
|
|
| 482 | - if(isset($this->inputs[$key])){
|
|
| 481 | + else {
|
|
| 482 | + if (isset($this->inputs[$key])) {
|
|
| 483 | 483 | $keyMethod = $this->{$method}();
|
| 484 | 484 | $this->inputs[$key] = $keyMethod; |
| 485 | 485 | } |
@@ -495,22 +495,22 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | private function validation() |
| 497 | 497 | {
|
| 498 | - if(property_exists($this,'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
|
|
| 498 | + if (property_exists($this, 'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
|
|
| 499 | 499 | $this->autoValidate('autoObjectValidate');
|
| 500 | 500 | } |
| 501 | 501 | // we need to find the rule method |
| 502 | 502 | // because we can not validate it. |
| 503 | - if(method_exists($this,'rule')){
|
|
| 503 | + if (method_exists($this, 'rule')) {
|
|
| 504 | 504 | $this->rule(); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | // if we only want to make a rule of |
| 508 | 508 | // the specified request object, we will use |
| 509 | 509 | // the rule method with the prefix of the request object. |
| 510 | - $validName=strtolower(str_replace('Request','',class_basename($this))).'Rule';
|
|
| 510 | + $validName = strtolower(str_replace('Request', '', class_basename($this))).'Rule';
|
|
| 511 | 511 | |
| 512 | 512 | //if the specified method exists; |
| 513 | - if(method_exists($this,$validName)){
|
|
| 513 | + if (method_exists($this, $validName)) {
|
|
| 514 | 514 | $this->{$validName}();
|
| 515 | 515 | } |
| 516 | 516 | } |
@@ -214,8 +214,7 @@ discard block |
||
| 214 | 214 | if(!isset($this->inputs[$generator])){
|
| 215 | 215 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 216 | 216 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 217 | - } |
|
| 218 | - else {
|
|
| 217 | + } else {
|
|
| 219 | 218 | |
| 220 | 219 | if($this->checkProperties('auto_generators_dont_overwrite')
|
| 221 | 220 | && in_array($generator,$this->auto_generators_dont_overwrite)){
|
@@ -358,22 +357,19 @@ discard block |
||
| 358 | 357 | if(isset($exceptionParamList[$key])){
|
| 359 | 358 | $keyParams = ($exceptionParamList[$key]['params']) ?? []; |
| 360 | 359 | exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 361 | - } |
|
| 362 | - else{
|
|
| 360 | + } else{
|
|
| 363 | 361 | exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 364 | 362 | } |
| 365 | 363 | } |
| 366 | 364 | } |
| 367 | 365 | |
| 368 | - } |
|
| 369 | - else{
|
|
| 366 | + } else{
|
|
| 370 | 367 | |
| 371 | 368 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
| 372 | 369 | if(isset($exceptionParamList[$key])){
|
| 373 | 370 | $keyParams = ($exceptionParamList[$key]['params']) ?? []; |
| 374 | 371 | exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 375 | - } |
|
| 376 | - else{
|
|
| 372 | + } else{
|
|
| 377 | 373 | exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
|
| 378 | 374 | } |
| 379 | 375 | } |
@@ -477,8 +473,7 @@ discard block |
||
| 477 | 473 | $keyMethod = $this->{$method}();
|
| 478 | 474 | $this->inputs[$key][] = $keyMethod; |
| 479 | 475 | } |
| 480 | - } |
|
| 481 | - else{
|
|
| 476 | + } else{
|
|
| 482 | 477 | if(isset($this->inputs[$key])){
|
| 483 | 478 | $keyMethod = $this->{$method}();
|
| 484 | 479 | $this->inputs[$key] = $keyMethod; |
@@ -7,32 +7,32 @@ |
||
| 7 | 7 | /** |
| 8 | 8 | * @return mixed |
| 9 | 9 | */ |
| 10 | - public function handle() |
|
| 11 | - {
|
|
| 12 | - return $this->getConfigAliasGroup(); |
|
| 13 | - } |
|
| 10 | + public function handle() |
|
| 11 | + {
|
|
| 12 | + return $this->getConfigAliasGroup(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @return array |
| 17 | 17 | */ |
| 18 | - public function getConfigAliasGroup() |
|
| 19 | - {
|
|
| 20 | - $aliasGroup=app()->namespace()->config().'\AliasGroup'; |
|
| 21 | - if(class_exists($aliasGroup)){
|
|
| 22 | - return app()->resolve($aliasGroup)->handle(); |
|
| 23 | - } |
|
| 24 | - return []; |
|
| 25 | - } |
|
| 18 | + public function getConfigAliasGroup() |
|
| 19 | + {
|
|
| 20 | + $aliasGroup=app()->namespace()->config().'\AliasGroup'; |
|
| 21 | + if(class_exists($aliasGroup)){
|
|
| 22 | + return app()->resolve($aliasGroup)->handle(); |
|
| 23 | + } |
|
| 24 | + return []; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param $object |
| 29 | 29 | * @param $name |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | - public static function setAlias($object,$name) |
|
| 33 | - {
|
|
| 34 | - if((new $object) instanceof $name === false){
|
|
| 35 | - class_alias($object,$name); |
|
| 36 | - } |
|
| 37 | - } |
|
| 32 | + public static function setAlias($object,$name) |
|
| 33 | + {
|
|
| 34 | + if((new $object) instanceof $name === false){
|
|
| 35 | + class_alias($object,$name); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function getConfigAliasGroup() |
| 19 | 19 | {
|
| 20 | - $aliasGroup=app()->namespace()->config().'\AliasGroup'; |
|
| 21 | - if(class_exists($aliasGroup)){
|
|
| 20 | + $aliasGroup = app()->namespace()->config().'\AliasGroup'; |
|
| 21 | + if (class_exists($aliasGroup)) {
|
|
| 22 | 22 | return app()->resolve($aliasGroup)->handle(); |
| 23 | 23 | } |
| 24 | 24 | return []; |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | * @param $name |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | - public static function setAlias($object,$name) |
|
| 32 | + public static function setAlias($object, $name) |
|
| 33 | 33 | {
|
| 34 | - if((new $object) instanceof $name === false){
|
|
| 35 | - class_alias($object,$name); |
|
| 34 | + if ((new $object) instanceof $name===false) {
|
|
| 35 | + class_alias($object, $name); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public function exclude() |
| 32 | 32 | {
|
| 33 | 33 | return [ |
| 34 | - 'all'=>['hook','login','logout'] |
|
| 34 | + 'all'=>['hook', 'login', 'logout'] |
|
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | foreach ($array as $values) {
|
| 46 | 46 | if ($values instanceof Collection) {
|
| 47 | 47 | $values = $values->all(); |
| 48 | - } elseif (! is_array($values)) {
|
|
| 48 | + } elseif (!is_array($values)) {
|
|
| 49 | 49 | continue; |
| 50 | 50 | } |
| 51 | 51 | $results = array_merge($results, $values); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | {
|
| 95 | 95 | $results = []; |
| 96 | 96 | foreach ($array as $key => $value) {
|
| 97 | - if (is_array($value) && ! empty($value)) {
|
|
| 97 | + if (is_array($value) && !empty($value)) {
|
|
| 98 | 98 | $results = array_merge($results, static::dot($value, $prepend.$key.'.')); |
| 99 | 99 | } else {
|
| 100 | 100 | $results[$prepend.$key] = $value; |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | $result = []; |
| 181 | 181 | foreach ($array as $item) {
|
| 182 | 182 | $item = $item instanceof Collection ? $item->all() : $item; |
| 183 | - if (! is_array($item)) {
|
|
| 183 | + if (!is_array($item)) {
|
|
| 184 | 184 | $result[] = $item; |
| 185 | - } elseif ($depth === 1) {
|
|
| 185 | + } elseif ($depth===1) {
|
|
| 186 | 186 | $result = array_merge($result, array_values($item)); |
| 187 | 187 | } else {
|
| 188 | - $result = array_merge($result, static::flatten($item, $depth - 1)); |
|
| 188 | + $result = array_merge($result, static::flatten($item, $depth-1)); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | return $result; |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | public static function forget(&$array, $keys) |
| 201 | 201 | {
|
| 202 | 202 | $original = &$array; |
| 203 | - $keys = (array) $keys; |
|
| 204 | - if (count($keys) === 0) {
|
|
| 203 | + $keys = (array)$keys; |
|
| 204 | + if (count($keys)===0) {
|
|
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | 207 | foreach ($keys as $key) {
|
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $parts = explode('.', $key);
|
| 214 | 214 | // clean up before each pass |
| 215 | 215 | $array = &$original; |
| 216 | - while (count($parts) > 1) {
|
|
| 216 | + while (count($parts)>1) {
|
|
| 217 | 217 | $part = array_shift($parts); |
| 218 | 218 | if (isset($array[$part]) && is_array($array[$part])) {
|
| 219 | 219 | $array = &$array[$part]; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public static function get($array, $key, $default = null) |
| 236 | 236 | {
|
| 237 | - if (! static::accessible($array)) {
|
|
| 237 | + if (!static::accessible($array)) {
|
|
| 238 | 238 | return value($default); |
| 239 | 239 | } |
| 240 | 240 | if (is_null($key)) {
|
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | if (static::exists($array, $key)) {
|
| 244 | 244 | return $array[$key]; |
| 245 | 245 | } |
| 246 | - if (strpos($key, '.') === false) {
|
|
| 246 | + if (strpos($key, '.')===false) {
|
|
| 247 | 247 | return $array[$key] ?? value($default); |
| 248 | 248 | } |
| 249 | 249 | foreach (explode('.', $key) as $segment) {
|
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | if (is_null($keys)) {
|
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | - $keys = (array) $keys; |
|
| 271 | - if (! $array) {
|
|
| 270 | + $keys = (array)$keys; |
|
| 271 | + if (!$array) {
|
|
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | - if ($keys === []) {
|
|
| 274 | + if ($keys===[]) {
|
|
| 275 | 275 | return false; |
| 276 | 276 | } |
| 277 | 277 | foreach ($keys as $key) {
|
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | public static function isAssoc(array $array) |
| 301 | 301 | {
|
| 302 | 302 | $keys = array_keys($array); |
| 303 | - return array_keys($keys) !== $keys; |
|
| 303 | + return array_keys($keys)!==$keys; |
|
| 304 | 304 | } |
| 305 | 305 | /** |
| 306 | 306 | * Get a subset of the items from the given array. |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public static function only($array, $keys) |
| 313 | 313 | {
|
| 314 | - return array_intersect_key($array, array_flip((array) $keys)); |
|
| 314 | + return array_intersect_key($array, array_flip((array)$keys)); |
|
| 315 | 315 | } |
| 316 | 316 | /** |
| 317 | 317 | * Pluck an array of values from an array. |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | } else {
|
| 336 | 336 | $itemKey = data_get($item, $key); |
| 337 | 337 | if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
|
| 338 | - $itemKey = (string) $itemKey; |
|
| 338 | + $itemKey = (string)$itemKey; |
|
| 339 | 339 | } |
| 340 | 340 | $results[$itemKey] = $itemValue; |
| 341 | 341 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | if (is_null($key)) {
|
| 369 | 369 | array_unshift($array, $value); |
| 370 | 370 | } else {
|
| 371 | - $array = [$key => $value] + $array; |
|
| 371 | + $array = [$key => $value]+$array; |
|
| 372 | 372 | } |
| 373 | 373 | return $array; |
| 374 | 374 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | {
|
| 400 | 400 | $requested = is_null($number) ? 1 : $number; |
| 401 | 401 | $count = count($array); |
| 402 | - if ($requested > $count) {
|
|
| 402 | + if ($requested>$count) {
|
|
| 403 | 403 | throw new InvalidArgumentException( |
| 404 | 404 | "You requested {$requested} items, but there are only {$count} items available."
|
| 405 | 405 | ); |
@@ -407,12 +407,12 @@ discard block |
||
| 407 | 407 | if (is_null($number)) {
|
| 408 | 408 | return $array[array_rand($array)]; |
| 409 | 409 | } |
| 410 | - if ((int) $number === 0) {
|
|
| 410 | + if ((int)$number===0) {
|
|
| 411 | 411 | return []; |
| 412 | 412 | } |
| 413 | 413 | $keys = array_rand($array, $number); |
| 414 | 414 | $results = []; |
| 415 | - foreach ((array) $keys as $key) {
|
|
| 415 | + foreach ((array)$keys as $key) {
|
|
| 416 | 416 | $results[] = $array[$key]; |
| 417 | 417 | } |
| 418 | 418 | return $results; |
@@ -433,12 +433,12 @@ discard block |
||
| 433 | 433 | return $array = $value; |
| 434 | 434 | } |
| 435 | 435 | $keys = explode('.', $key);
|
| 436 | - while (count($keys) > 1) {
|
|
| 436 | + while (count($keys)>1) {
|
|
| 437 | 437 | $key = array_shift($keys); |
| 438 | 438 | // If the key doesn't exist at this depth, we will just create an empty array |
| 439 | 439 | // to hold the next value, allowing us to create the arrays to hold final |
| 440 | 440 | // values at the correct depth. Then we'll keep digging into the array. |
| 441 | - if (! isset($array[$key]) || ! is_array($array[$key])) {
|
|
| 441 | + if (!isset($array[$key]) || !is_array($array[$key])) {
|
|
| 442 | 442 | $array[$key] = []; |
| 443 | 443 | } |
| 444 | 444 | $array = &$array[$key]; |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | shuffle($array); |
| 460 | 460 | } else {
|
| 461 | 461 | srand($seed); |
| 462 | - usort($array, function () {
|
|
| 462 | + usort($array, function() {
|
|
| 463 | 463 | return rand(-1, 1); |
| 464 | 464 | }); |
| 465 | 465 | } |
@@ -536,16 +536,16 @@ discard block |
||
| 536 | 536 | * @param array $referenceArray |
| 537 | 537 | * @return array |
| 538 | 538 | */ |
| 539 | - public static function removeSameValues($removeArray=array(),$referenceArray=array()) |
|
| 539 | + public static function removeSameValues($removeArray = array(), $referenceArray = array()) |
|
| 540 | 540 | {
|
| 541 | 541 | $list = []; |
| 542 | 542 | |
| 543 | - foreach ($removeArray as $remove){
|
|
| 544 | - if(!in_array($remove,$referenceArray)){
|
|
| 545 | - $list[]=$remove; |
|
| 543 | + foreach ($removeArray as $remove) {
|
|
| 544 | + if (!in_array($remove, $referenceArray)) {
|
|
| 545 | + $list[] = $remove; |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | - return array_merge($referenceArray,$list); |
|
| 548 | + return array_merge($referenceArray, $list); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | * @param $key |
| 554 | 554 | * @return null |
| 555 | 555 | */ |
| 556 | - public static function isset($array,$key) |
|
| 556 | + public static function isset($array, $key) |
|
| 557 | 557 | {
|
| 558 | - if(isset($array[$key])){
|
|
| 558 | + if (isset($array[$key])) {
|
|
| 559 | 559 | return $array[$key]; |
| 560 | 560 | } |
| 561 | 561 | return null; |
@@ -566,13 +566,13 @@ discard block |
||
| 566 | 566 | * @param null $withKey |
| 567 | 567 | * @return bool |
| 568 | 568 | */ |
| 569 | - public static function isArrayWithCount($array,$withKey=null) |
|
| 569 | + public static function isArrayWithCount($array, $withKey = null) |
|
| 570 | 570 | {
|
| 571 | - if($withKey===null){
|
|
| 571 | + if ($withKey===null) {
|
|
| 572 | 572 | return is_array($array) && count($array); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - return isset($array[$withKey]) && self::isArrayWithCount($array[$withKey],null); |
|
| 575 | + return isset($array[$withKey]) && self::isArrayWithCount($array[$withKey], null); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -580,12 +580,12 @@ discard block |
||
| 580 | 580 | * @param $array2 |
| 581 | 581 | * @return int |
| 582 | 582 | */ |
| 583 | - public static function arrayDiffKey($array1,$array2) |
|
| 583 | + public static function arrayDiffKey($array1, $array2) |
|
| 584 | 584 | {
|
| 585 | - $forArray1 = array_diff_key($array1,$array2); |
|
| 586 | - $forArray2 = array_diff_key($array2,$array1); |
|
| 585 | + $forArray1 = array_diff_key($array1, $array2); |
|
| 586 | + $forArray2 = array_diff_key($array2, $array1); |
|
| 587 | 587 | |
| 588 | - if(count($forArray1)=="0" && count($forArray2)=="0"){
|
|
| 588 | + if (count($forArray1)=="0" && count($forArray2)=="0") {
|
|
| 589 | 589 | return true; |
| 590 | 590 | } |
| 591 | 591 | return false; |
@@ -597,12 +597,12 @@ discard block |
||
| 597 | 597 | * @param $original |
| 598 | 598 | * @param array $overwrite |
| 599 | 599 | */ |
| 600 | - public static function overwriteWith($original,$overwrite=array()) |
|
| 600 | + public static function overwriteWith($original, $overwrite = array()) |
|
| 601 | 601 | {
|
| 602 | - foreach ($original as $key=>$item){
|
|
| 602 | + foreach ($original as $key=>$item) {
|
|
| 603 | 603 | |
| 604 | - if(array_key_exists($key,$overwrite)){
|
|
| 605 | - array_splice($original,$key,0,$overwrite[$key]); |
|
| 604 | + if (array_key_exists($key, $overwrite)) {
|
|
| 605 | + array_splice($original, $key, 0, $overwrite[$key]); |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public static function getSupportedVersions() |
| 18 | 18 | {
|
| 19 | - if(self::checkSupportedVersions()){
|
|
| 20 | - static::$supportedVersions = array_merge(static::$supportedVersions,static::supportedVersions()); |
|
| 19 | + if (self::checkSupportedVersions()) {
|
|
| 20 | + static::$supportedVersions = array_merge(static::$supportedVersions, static::supportedVersions()); |
|
| 21 | 21 | } |
| 22 | 22 | return static::$supportedVersions; |
| 23 | 23 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | private static function checkSupportedVersions() |
| 31 | 31 | {
|
| 32 | - return method_exists(static::class,'supportedVersions') |
|
| 32 | + return method_exists(static::class, 'supportedVersions') |
|
| 33 | 33 | && is_array(static::supportedVersions()); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | * @param $command |
| 20 | 20 | * @param $args |
| 21 | 21 | */ |
| 22 | - public function __construct($command,$args) |
|
| 22 | + public function __construct($command, $args) |
|
| 23 | 23 | {
|
| 24 | 24 | $this->arguments[] = 'php'; |
| 25 | 25 | $this->arguments[] = 'api'; |
| 26 | - $this->arguments = array_merge($this->arguments,explode(" ",$command));
|
|
| 26 | + $this->arguments = array_merge($this->arguments, explode(" ", $command));
|
|
| 27 | 27 | $this->arguments[] = strtolower(app); |
| 28 | 28 | $this->arguments[] = $args; |
| 29 | 29 | } |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function handle() |
| 37 | 37 | {
|
| 38 | - $process = new ProcessHandler($this->arguments,root.''); |
|
| 38 | + $process = new ProcessHandler($this->arguments, root.''); |
|
| 39 | 39 | $process->start(); |
| 40 | 40 | |
| 41 | 41 | foreach ($process as $type => $data) {
|
| 42 | - if ($process::OUT !== $type) {
|
|
| 42 | + if ($process::OUT!==$type) {
|
|
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | return true; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct($namespace = null) |
| 32 | 32 | {
|
| 33 | - if($namespace!==null){
|
|
| 33 | + if ($namespace!==null) {
|
|
| 34 | 34 | $this->namespace = $namespace; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function __invoke($namespace = null) |
| 43 | 43 | {
|
| 44 | - if($namespace!==null){
|
|
| 44 | + if ($namespace!==null) {
|
|
| 45 | 45 | $this->namespace = $namespace; |
| 46 | 46 | } |
| 47 | 47 | return $this; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function getReflectionClass() |
| 56 | 56 | {
|
| 57 | - if(!isset(static::$singletons['reflectionClass'])){
|
|
| 57 | + if (!isset(static::$singletons['reflectionClass'])) {
|
|
| 58 | 58 | static::$singletons['reflectionClass'] = new \ReflectionClass($this->namespace); |
| 59 | 59 | } |
| 60 | 60 | return static::$singletons['reflectionClass']; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getReflectionMethod($method) |
| 70 | 70 | {
|
| 71 | - return new \ReflectionMethod($this->namespace,$method); |
|
| 71 | + return new \ReflectionMethod($this->namespace, $method); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -7,14 +7,14 @@ |
||
| 7 | 7 | /** |
| 8 | 8 | * @var array $bootLoaders |
| 9 | 9 | */ |
| 10 | - protected static $bootLoaders = ['url','logger']; |
|
| 10 | + protected static $bootLoaders = ['url', 'logger']; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * load bootstrapper dependencies |
| 14 | 14 | * |
| 15 | 15 | * @param array $loaders |
| 16 | 16 | */ |
| 17 | - public static function bootLoader($loaders=array()) |
|
| 17 | + public static function bootLoader($loaders = array()) |
|
| 18 | 18 | {
|
| 19 | 19 | app()->loadIfNotExistBoot($loaders); |
| 20 | 20 | } |