@@ -54,25 +54,25 @@ discard block |
||
| 54 | 54 | private function autoValidate($validate) |
| 55 | 55 | {
|
| 56 | 56 | //we get the values to auto-validate. |
| 57 | - foreach ($this->{$validate} as $object=>$datas){
|
|
| 57 | + foreach ($this->{$validate} as $object=>$datas) {
|
|
| 58 | 58 | |
| 59 | 59 | // the auto-validate value must necessarily represent a class. |
| 60 | 60 | // otherwise auto-validate is not used. |
| 61 | - if(Utils::isNamespaceExists($object)){
|
|
| 61 | + if (Utils::isNamespaceExists($object)) {
|
|
| 62 | 62 | $getObjectInstance = app()->resolve($object); |
| 63 | 63 | |
| 64 | 64 | // we get the index values, |
| 65 | 65 | // which are called methods of the auto-validate value that represents the class. |
| 66 | - foreach ($datas as $dataKey=>$data){
|
|
| 66 | + foreach ($datas as $dataKey=>$data) {
|
|
| 67 | 67 | |
| 68 | 68 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
| 69 | 69 | // the process of auto-validate automatic implementation will be completed. |
| 70 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
|
|
| 71 | - if(isset($this->origin[$data])){
|
|
| 72 | - if(!is_array($this->origin[$data])){
|
|
| 70 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
|
|
| 71 | + if (isset($this->origin[$data])) {
|
|
| 72 | + if (!is_array($this->origin[$data])) {
|
|
| 73 | 73 | $this->origin[$data] = array($this->origin[$data]); |
| 74 | 74 | } |
| 75 | - foreach ($this->origin[$data] as $originData){
|
|
| 75 | + foreach ($this->origin[$data] as $originData) {
|
|
| 76 | 76 | $getObjectInstance->{$data}($originData);
|
| 77 | 77 | } |
| 78 | 78 | } |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // Determines which HTTP method |
| 96 | 96 | // the request object will be exposed to. |
| 97 | - if($this->checkProperties('http')){
|
|
| 97 | + if ($this->checkProperties('http')) {
|
|
| 98 | 98 | |
| 99 | 99 | // if the current http method does not exist |
| 100 | 100 | // in the http object, the exception will be thrown. |
| 101 | - if(!in_array($method,$this->http)){
|
|
| 101 | + if (!in_array($method, $this->http)) {
|
|
| 102 | 102 | |
| 103 | 103 | //exception batMethodCall |
| 104 | 104 | exception()->badMethodCall( |
| 105 | 105 | 'Invalid http method process for |
| 106 | - '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
|
|
| 106 | + '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
|
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | {
|
| 119 | 119 | // from the properties of the object properties to |
| 120 | 120 | // the existing variables, control the array and at least one element. |
| 121 | - return (property_exists($this,$properties) |
|
| 121 | + return (property_exists($this, $properties) |
|
| 122 | 122 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
|
| 123 | 123 | } |
| 124 | 124 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | {
|
| 132 | 132 | // we are saving the expected values for the request in container. |
| 133 | 133 | // this record can be returned in exception information. |
| 134 | - app()->register('requestExpected',$this->expected);
|
|
| 134 | + app()->register('requestExpected', $this->expected);
|
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | public function except($except) |
| 144 | 144 | {
|
| 145 | 145 | // the except parameter is a callable value. |
| 146 | - if(is_callable($except)){
|
|
| 147 | - $call = call_user_func_array($except,[$this]); |
|
| 146 | + if (is_callable($except)) {
|
|
| 147 | + $call = call_user_func_array($except, [$this]); |
|
| 148 | 148 | $except = $call; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // except with the except exceptions property |
| 152 | 152 | // and then assigning them to the inputs property. |
| 153 | - $this->except = array_merge($this->except,$except); |
|
| 154 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
| 153 | + $this->except = array_merge($this->except, $except); |
|
| 154 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
| 155 | 155 | |
| 156 | 156 | return $this; |
| 157 | 157 | } |
@@ -165,28 +165,28 @@ discard block |
||
| 165 | 165 | {
|
| 166 | 166 | // expected method is executed. |
| 167 | 167 | // this method is a must for http method values to be found in this property. |
| 168 | - if($this->checkProperties('expected')){
|
|
| 168 | + if ($this->checkProperties('expected')) {
|
|
| 169 | 169 | |
| 170 | 170 | // if the expected values are not found in the inputs array, |
| 171 | 171 | // the exception will be thrown. |
| 172 | - foreach ($this->expected as $expected){
|
|
| 172 | + foreach ($this->expected as $expected) {
|
|
| 173 | 173 | |
| 174 | 174 | $expectedValues = []; |
| 175 | 175 | |
| 176 | 176 | // mandatory expected data for each key can be separated by | operator. |
| 177 | 177 | // this is evaluated as "or". |
| 178 | - foreach($expectedData = explode("|",$expected) as $inputs){
|
|
| 179 | - if(!isset($this->inputs[$inputs])){
|
|
| 178 | + foreach ($expectedData = explode("|", $expected) as $inputs) {
|
|
| 179 | + if (!isset($this->inputs[$inputs])) {
|
|
| 180 | 180 | $expectedValues[] = $inputs; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // if the expectedData and expectedValues |
| 185 | 185 | // array are numerically equal to the expected key, the exception is thrown. |
| 186 | - if(count($expectedData)===count($expectedValues)){
|
|
| 186 | + if (count($expectedData)===count($expectedValues)) {
|
|
| 187 | 187 | exception() |
| 188 | 188 | ->unexpectedValue('You absolutely have to send the value
|
| 189 | - '.implode(" or ",$expectedValues).' for request object');
|
|
| 189 | + '.implode(" or ", $expectedValues).' for request object');
|
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | {
|
| 202 | 202 | // check the presence of the generator object |
| 203 | 203 | // and operate the generator over this object. |
| 204 | - if($this->checkProperties('auto_generators')){
|
|
| 204 | + if ($this->checkProperties('auto_generators')) {
|
|
| 205 | 205 | $generators = $this->getAutoGenerators(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // check the presence of the generator object |
| 209 | 209 | // and operate the generator over this object. |
| 210 | - if($this->checkProperties('generators')){
|
|
| 211 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
| 210 | + if ($this->checkProperties('generators')) {
|
|
| 211 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if(isset($generators)){
|
|
| 214 | + if (isset($generators)) {
|
|
| 215 | 215 | $this->generatorMethod($generators); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -224,30 +224,30 @@ discard block |
||
| 224 | 224 | private function generatorMethod($generators) |
| 225 | 225 | {
|
| 226 | 226 | //generator array object |
| 227 | - foreach ($generators as $generator){
|
|
| 227 | + foreach ($generators as $generator) {
|
|
| 228 | 228 | |
| 229 | 229 | //generator method name |
| 230 | 230 | $generatorMethodName = $generator.'Generator'; |
| 231 | 231 | |
| 232 | 232 | // if the generator method is present, |
| 233 | 233 | // the fake value is assigned. |
| 234 | - if(method_exists($this,$generatorMethodName)){
|
|
| 234 | + if (method_exists($this, $generatorMethodName)) {
|
|
| 235 | 235 | |
| 236 | 236 | //fake registration |
| 237 | - if(!isset($this->inputs[$generator])){
|
|
| 237 | + if (!isset($this->inputs[$generator])) {
|
|
| 238 | 238 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 239 | 239 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 240 | 240 | } |
| 241 | 241 | else {
|
| 242 | 242 | |
| 243 | - if($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 244 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
|
| 243 | + if ($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 244 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) {
|
|
| 245 | 245 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 246 | 246 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if($this->checkProperties('generators_dont_overwrite')
|
|
| 250 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){
|
|
| 249 | + if ($this->checkProperties('generators_dont_overwrite')
|
|
| 250 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) {
|
|
| 251 | 251 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 252 | 252 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 253 | 253 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | {
|
| 293 | 293 | // we use the http method to write |
| 294 | 294 | // the values to the inputs and origin properties. |
| 295 | - foreach($this->requestHttp->resolve() as $key=>$value){
|
|
| 295 | + foreach ($this->requestHttp->resolve() as $key=>$value) {
|
|
| 296 | 296 | |
| 297 | 297 | //inputs and origin properties |
| 298 | 298 | $this->inputs[$key] = $value; |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | // we update the input values after |
| 338 | 338 | // we receive and check the saved objects. |
| 339 | - foreach ($clientObjects as $key=>$value){
|
|
| 339 | + foreach ($clientObjects as $key=>$value) {
|
|
| 340 | 340 | |
| 341 | - if(isset($clientObjects['origin'][$key])){
|
|
| 341 | + if (isset($clientObjects['origin'][$key])) {
|
|
| 342 | 342 | |
| 343 | 343 | $this->{$key} = $clientObjects['origin'][$key];
|
| 344 | 344 | $this->inputs[$key] = $this->{$key};
|
@@ -363,11 +363,11 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | // the request update to be performed using |
| 365 | 365 | // the method name to be used with the http method. |
| 366 | - $this->setRequestInputs($requestMethod,$key); |
|
| 366 | + $this->setRequestInputs($requestMethod, $key); |
|
| 367 | 367 | |
| 368 | 368 | // the request update to be performed using |
| 369 | 369 | // the method name to be used without the http method. |
| 370 | - $this->setRequestInputs($key,$key); |
|
| 370 | + $this->setRequestInputs($key, $key); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -376,28 +376,28 @@ discard block |
||
| 376 | 376 | * @param $method |
| 377 | 377 | * @param $key |
| 378 | 378 | */ |
| 379 | - private function setRequestInputs($method,$key) |
|
| 379 | + private function setRequestInputs($method, $key) |
|
| 380 | 380 | {
|
| 381 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
|
|
| 381 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
|
|
| 382 | 382 | |
| 383 | 383 | //check annotations for method |
| 384 | - $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]); |
|
| 385 | - $annotation->annotation($method,$key); |
|
| 384 | + $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]); |
|
| 385 | + $annotation->annotation($method, $key); |
|
| 386 | 386 | |
| 387 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
|
|
| 387 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
|
|
| 388 | 388 | |
| 389 | 389 | $inputKeys = $this->inputs[$key]; |
| 390 | 390 | |
| 391 | 391 | $this->inputs[$key] = []; |
| 392 | - foreach ($inputKeys as $input){
|
|
| 392 | + foreach ($inputKeys as $input) {
|
|
| 393 | 393 | |
| 394 | 394 | $this->{$key} = $input;
|
| 395 | 395 | $keyMethod = $this->{$method}();
|
| 396 | 396 | $this->inputs[$key][] = $keyMethod; |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | - else{
|
|
| 400 | - if(isset($this->inputs[$key])){
|
|
| 399 | + else {
|
|
| 400 | + if (isset($this->inputs[$key])) {
|
|
| 401 | 401 | $keyMethod = $this->{$method}();
|
| 402 | 402 | $this->inputs[$key] = $keyMethod; |
| 403 | 403 | } |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | {
|
| 416 | 416 | // the auto object validate property is the property |
| 417 | 417 | // where all of your request values are automatically validated. |
| 418 | - if(property_exists($this,'autoObjectValidate') |
|
| 419 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
|
|
| 418 | + if (property_exists($this, 'autoObjectValidate') |
|
| 419 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
|
|
| 420 | 420 | $this->autoValidate('autoObjectValidate');
|
| 421 | 421 | } |
| 422 | 422 | } |
@@ -237,8 +237,7 @@ discard block |
||
| 237 | 237 | if(!isset($this->inputs[$generator])){
|
| 238 | 238 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 239 | 239 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 240 | - } |
|
| 241 | - else {
|
|
| 240 | + } else {
|
|
| 242 | 241 | |
| 243 | 242 | if($this->checkProperties('auto_generators_dont_overwrite')
|
| 244 | 243 | && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
@@ -395,8 +394,7 @@ discard block |
||
| 395 | 394 | $keyMethod = $this->{$method}();
|
| 396 | 395 | $this->inputs[$key][] = $keyMethod; |
| 397 | 396 | } |
| 398 | - } |
|
| 399 | - else{
|
|
| 397 | + } else{
|
|
| 400 | 398 | if(isset($this->inputs[$key])){
|
| 401 | 399 | $keyMethod = $this->{$method}();
|
| 402 | 400 | $this->inputs[$key] = $keyMethod; |