@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param ApplicationContracts $app |
| 26 | 26 | * @param $request |
| 27 | 27 | */ |
| 28 | - public function __construct(ApplicationContracts $app,$request) |
|
| 28 | + public function __construct(ApplicationContracts $app, $request) |
|
| 29 | 29 | {
|
| 30 | 30 | parent::__construct($app); |
| 31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param $key |
| 42 | 42 | * @return mixed|void |
| 43 | 43 | */ |
| 44 | - public function annotation($method,$key) |
|
| 44 | + public function annotation($method, $key) |
|
| 45 | 45 | {
|
| 46 | 46 | //set annotation value with getting reflection |
| 47 | 47 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
|
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | * @param string $key |
| 67 | 67 | * @param null|string $data |
| 68 | 68 | */ |
| 69 | - private function catchException($key,$data) |
|
| 69 | + private function catchException($key, $data) |
|
| 70 | 70 | {
|
| 71 | - if(isset($this->exceptionParams[$key])){
|
|
| 71 | + if (isset($this->exceptionParams[$key])) {
|
|
| 72 | 72 | |
| 73 | 73 | //get key params for exception params |
| 74 | 74 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 75 | 75 | |
| 76 | 76 | //catch exception |
| 77 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
| 77 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
| 78 | 78 | ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')');
|
| 79 | 79 | } |
| 80 | - else{
|
|
| 80 | + else {
|
|
| 81 | 81 | //catch exception |
| 82 | 82 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 83 | 83 | } |
@@ -90,23 +90,23 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | private function getException($key) |
| 92 | 92 | {
|
| 93 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 93 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 94 | 94 | |
| 95 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 95 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 96 | 96 | |
| 97 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 98 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 97 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 98 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 99 | 99 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 102 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 103 | 103 | |
| 104 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 104 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 105 | 105 | unset($this->exceptionParams[$key]['params']); |
| 106 | 106 | |
| 107 | - foreach ($paramsCommaExplode as $params){
|
|
| 108 | - $paramsEqualExplode = explode("=",$params);
|
|
| 109 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 107 | + foreach ($paramsCommaExplode as $params) {
|
|
| 108 | + $paramsEqualExplode = explode("=", $params);
|
|
| 109 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 110 | 110 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -123,37 +123,37 @@ discard block |
||
| 123 | 123 | {
|
| 124 | 124 | // with the method based regex annotation, |
| 125 | 125 | // we check the rule definition for our requests. |
| 126 | - if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
|
|
| 127 | - if(isset($this->inputs[$key])){
|
|
| 126 | + if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
|
|
| 127 | + if (isset($this->inputs[$key])) {
|
|
| 128 | 128 | |
| 129 | 129 | // for the definition of rules, |
| 130 | 130 | // our inputs can be array and in this case we offer array option for user comfort. |
| 131 | - if(is_array($this->inputs[$key])){
|
|
| 131 | + if (is_array($this->inputs[$key])) {
|
|
| 132 | 132 | |
| 133 | - foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){
|
|
| 133 | + foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) {
|
|
| 134 | 134 | |
| 135 | - if(is_array($this->inputsValue)){
|
|
| 135 | + if (is_array($this->inputsValue)) {
|
|
| 136 | 136 | |
| 137 | - foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem){
|
|
| 138 | - if(!preg_match('@'.$regex[1].'@is',$inputsValueItem)){
|
|
| 139 | - $this->catchException($key,$regex[1]); |
|
| 137 | + foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem) {
|
|
| 138 | + if (!preg_match('@'.$regex[1].'@is', $inputsValueItem)) {
|
|
| 139 | + $this->catchException($key, $regex[1]); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | - else{
|
|
| 145 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
|
| 146 | - $this->catchException($key,$regex[1]); |
|
| 144 | + else {
|
|
| 145 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
|
|
| 146 | + $this->catchException($key, $regex[1]); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | - else{
|
|
| 152 | + else {
|
|
| 153 | 153 | |
| 154 | 154 | // we control the regex rule that evaluates when only string arrives. |
| 155 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 156 | - $this->catchException($key,$regex[1]); |
|
| 155 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 156 | + $this->catchException($key, $regex[1]); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | private function getRemove($key) |
| 170 | 170 | {
|
| 171 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
|
|
| 172 | - if(isset($this->inputs[$key])){
|
|
| 173 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 171 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
|
|
| 172 | + if (isset($this->inputs[$key])) {
|
|
| 173 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 174 | 174 | unset($this->inputs[$key]); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -184,42 +184,42 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | private function getRules($key) |
| 186 | 186 | {
|
| 187 | - if(preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is',$this->annotation,$rule)){
|
|
| 187 | + if (preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is', $this->annotation, $rule)) {
|
|
| 188 | 188 | |
| 189 | 189 | $requestRules = $this->getReflection('rules');
|
| 190 | 190 | |
| 191 | - $rules = explode(":",$rule[1]);
|
|
| 192 | - if(isset($this->inputs[$key]) && !is_array($this->inputs[$key])){
|
|
| 193 | - foreach($rules as $rule){
|
|
| 194 | - if(isset($requestRules[$rule])){
|
|
| 195 | - if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){
|
|
| 196 | - exception($rule,['key'=>$key.':'.$this->inputs[$key]]) |
|
| 191 | + $rules = explode(":", $rule[1]);
|
|
| 192 | + if (isset($this->inputs[$key]) && !is_array($this->inputs[$key])) {
|
|
| 193 | + foreach ($rules as $rule) {
|
|
| 194 | + if (isset($requestRules[$rule])) {
|
|
| 195 | + if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) {
|
|
| 196 | + exception($rule, ['key'=>$key.':'.$this->inputs[$key]]) |
|
| 197 | 197 | ->invalidArgument($key.':'.$this->inputs[$key].' input value is not valid for '.$rule.' request rule'); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - else{
|
|
| 202 | + else {
|
|
| 203 | 203 | |
| 204 | - foreach ($this->inputs[$key] as $ikey=>$input){
|
|
| 204 | + foreach ($this->inputs[$key] as $ikey=>$input) {
|
|
| 205 | 205 | |
| 206 | - if(!is_array($input)){
|
|
| 207 | - foreach($rules as $rule){
|
|
| 208 | - if(isset($requestRules[$rule])){
|
|
| 209 | - if(!preg_match('@'.$requestRules[$rule].'@',$input)){
|
|
| 210 | - exception($rule,['key'=>''.$key.':'.$input]) |
|
| 206 | + if (!is_array($input)) {
|
|
| 207 | + foreach ($rules as $rule) {
|
|
| 208 | + if (isset($requestRules[$rule])) {
|
|
| 209 | + if (!preg_match('@'.$requestRules[$rule].'@', $input)) {
|
|
| 210 | + exception($rule, ['key'=>''.$key.':'.$input]) |
|
| 211 | 211 | ->invalidArgument($input.' input value is not valid for '.$rule.' request rule'); |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - else{
|
|
| 216 | + else {
|
|
| 217 | 217 | |
| 218 | - foreach ($input as $ikey=>$item){
|
|
| 219 | - foreach($rules as $rule){
|
|
| 220 | - if(isset($requestRules[$rule])){
|
|
| 221 | - if(!preg_match('@'.$requestRules[$rule].'@',$item)){
|
|
| 222 | - exception($rule,['key'=>''.$key.':'.$item]) |
|
| 218 | + foreach ($input as $ikey=>$item) {
|
|
| 219 | + foreach ($rules as $rule) {
|
|
| 220 | + if (isset($requestRules[$rule])) {
|
|
| 221 | + if (!preg_match('@'.$requestRules[$rule].'@', $item)) {
|
|
| 222 | + exception($rule, ['key'=>''.$key.':'.$item]) |
|
| 223 | 223 | ->invalidArgument($item.' input value is not valid for '.$rule.' request rule'); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @throws ReflectionExceptionAlias |
| 71 | 71 | */ |
| 72 | - public function __construct($clientData=null) |
|
| 72 | + public function __construct($clientData = null) |
|
| 73 | 73 | {
|
| 74 | 74 | //reflection process |
| 75 | 75 | $this->reflection = app()['reflection']($this); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $this->setClientName(); |
| 79 | 79 | |
| 80 | 80 | //get http method via request http manager class |
| 81 | - $this->requestHttp = app()->resolve(ClientHttpManager::class,['client'=>$this]); |
|
| 81 | + $this->requestHttp = app()->resolve(ClientHttpManager::class, ['client'=>$this]); |
|
| 82 | 82 | |
| 83 | 83 | //get request client data |
| 84 | 84 | $this->clientData = ($clientData===null) ? $this->requestHttp->resolve() : $clientData; |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | private function autoValidate($validate) |
| 96 | 96 | {
|
| 97 | 97 | //we get the values to auto-validate. |
| 98 | - foreach ($this->{$validate} as $object=>$datas){
|
|
| 98 | + foreach ($this->{$validate} as $object=>$datas) {
|
|
| 99 | 99 | |
| 100 | - if(false===Utils::isNamespaceExists($object)){
|
|
| 100 | + if (false===Utils::isNamespaceExists($object)) {
|
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // we get the index values, |
| 109 | 109 | // which are called methods of the auto-validate value that represents the class. |
| 110 | - foreach ($datas as $dataKey=>$data){
|
|
| 110 | + foreach ($datas as $dataKey=>$data) {
|
|
| 111 | 111 | |
| 112 | 112 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
| 113 | 113 | // the process of auto-validate automatic implementation will be completed. |
| 114 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data) && isset($this->origin[$data])){
|
|
| 115 | - if(!is_array($this->origin[$data])){
|
|
| 114 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data) && isset($this->origin[$data])) {
|
|
| 115 | + if (!is_array($this->origin[$data])) {
|
|
| 116 | 116 | $this->origin[$data] = array($this->origin[$data]); |
| 117 | 117 | } |
| 118 | - foreach ($this->origin[$data] as $originData){
|
|
| 118 | + foreach ($this->origin[$data] as $originData) {
|
|
| 119 | 119 | $getObjectInstance->{$data}($originData);
|
| 120 | 120 | } |
| 121 | 121 | } |
@@ -131,22 +131,22 @@ discard block |
||
| 131 | 131 | private function capsule() |
| 132 | 132 | {
|
| 133 | 133 | //a process can be added to the capsule array using the method. |
| 134 | - if(method_exists($this,'capsuleMethod')){
|
|
| 135 | - $this->capsule = array_merge($this->capsule,$this->capsuleMethod()); |
|
| 134 | + if (method_exists($this, 'capsuleMethod')) {
|
|
| 135 | + $this->capsule = array_merge($this->capsule, $this->capsuleMethod()); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // expected method is executed. |
| 139 | 139 | // this method is a must for http method values to be found in this property. |
| 140 | - if($this->checkProperties('capsule')){
|
|
| 140 | + if ($this->checkProperties('capsule')) {
|
|
| 141 | 141 | |
| 142 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){
|
|
| 143 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
| 142 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) {
|
|
| 143 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - foreach($this->inputs as $input=>$value){
|
|
| 146 | + foreach ($this->inputs as $input=>$value) {
|
|
| 147 | 147 | |
| 148 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){
|
|
| 149 | - exception('clientCapsule',['key'=>$input])
|
|
| 148 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) {
|
|
| 149 | + exception('clientCapsule', ['key'=>$input])
|
|
| 150 | 150 | ->overflow('The '.$input.' value cannot be sent.');
|
| 151 | 151 | } |
| 152 | 152 | } |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | // Determines which HTTP method |
| 167 | 167 | // the request object will be exposed to. |
| 168 | - if($this->checkProperties('http')){
|
|
| 168 | + if ($this->checkProperties('http')) {
|
|
| 169 | 169 | |
| 170 | 170 | // if the current http method does not exist |
| 171 | 171 | // in the http object, the exception will be thrown. |
| 172 | - if(!in_array($method,$this->http)){
|
|
| 172 | + if (!in_array($method, $this->http)) {
|
|
| 173 | 173 | |
| 174 | 174 | //exception batMethodCall |
| 175 | 175 | exception()->badMethodCall( |
| 176 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
|
|
| 176 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
|
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | {
|
| 189 | 189 | // from the properties of the object properties to |
| 190 | 190 | // the existing variables, control the array and at least one element. |
| 191 | - return (property_exists($this,$properties) |
|
| 191 | + return (property_exists($this, $properties) |
|
| 192 | 192 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
|
| 193 | 193 | } |
| 194 | 194 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | {
|
| 202 | 202 | // we are saving the expected values for the request in container. |
| 203 | 203 | // this record can be returned in exception information. |
| 204 | - app()->register('requestExpected',$this->expected);
|
|
| 204 | + app()->register('requestExpected', $this->expected);
|
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | public function except($except) |
| 214 | 214 | {
|
| 215 | 215 | // the except parameter is a callable value. |
| 216 | - if(is_callable($except)){
|
|
| 217 | - $call = call_user_func_array($except,[$this]); |
|
| 216 | + if (is_callable($except)) {
|
|
| 217 | + $call = call_user_func_array($except, [$this]); |
|
| 218 | 218 | $except = $call; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // except with the except exceptions property |
| 222 | 222 | // and then assigning them to the inputs property. |
| 223 | - $this->except = array_merge($this->except,$except); |
|
| 224 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
| 223 | + $this->except = array_merge($this->except, $except); |
|
| 224 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
| 225 | 225 | |
| 226 | 226 | return $this; |
| 227 | 227 | } |
@@ -235,27 +235,27 @@ discard block |
||
| 235 | 235 | {
|
| 236 | 236 | // expected method is executed. |
| 237 | 237 | // this method is a must for http method values to be found in this property. |
| 238 | - if($this->checkProperties('expected')){
|
|
| 238 | + if ($this->checkProperties('expected')) {
|
|
| 239 | 239 | |
| 240 | 240 | // if the expected values are not found in the inputs array, |
| 241 | 241 | // the exception will be thrown. |
| 242 | - foreach ($this->expected as $expected){
|
|
| 242 | + foreach ($this->expected as $expected) {
|
|
| 243 | 243 | |
| 244 | 244 | $expectedValues = []; |
| 245 | 245 | |
| 246 | 246 | // mandatory expected data for each key can be separated by | operator. |
| 247 | 247 | // this is evaluated as "or". |
| 248 | - foreach($expectedData = explode("|",$expected) as $inputs){
|
|
| 249 | - if(!isset($this->inputs[$inputs])){
|
|
| 248 | + foreach ($expectedData = explode("|", $expected) as $inputs) {
|
|
| 249 | + if (!isset($this->inputs[$inputs])) {
|
|
| 250 | 250 | $expectedValues[$inputs] = $inputs; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // if the expectedData and expectedValues |
| 255 | 255 | // array are numerically equal to the expected key, the exception is thrown. |
| 256 | - if(count($expectedData)===count($expectedValues)){
|
|
| 257 | - exception('clientExpected',['key'=>$expected])
|
|
| 258 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object');
|
|
| 256 | + if (count($expectedData)===count($expectedValues)) {
|
|
| 257 | + exception('clientExpected', ['key'=>$expected])
|
|
| 258 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object');
|
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -270,17 +270,17 @@ discard block |
||
| 270 | 270 | {
|
| 271 | 271 | // check the presence of the generator object |
| 272 | 272 | // and operate the generator over this object. |
| 273 | - if($this->checkProperties('auto_generators')){
|
|
| 273 | + if ($this->checkProperties('auto_generators')) {
|
|
| 274 | 274 | $generators = $this->getAutoGenerators(); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // check the presence of the generator object |
| 278 | 278 | // and operate the generator over this object. |
| 279 | - if($this->checkProperties('generators')){
|
|
| 280 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
| 279 | + if ($this->checkProperties('generators')) {
|
|
| 280 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if(isset($generators)){
|
|
| 283 | + if (isset($generators)) {
|
|
| 284 | 284 | $this->generatorMethod($generators); |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -295,21 +295,21 @@ discard block |
||
| 295 | 295 | private function generatorMethod($generators) |
| 296 | 296 | {
|
| 297 | 297 | //generator array object |
| 298 | - foreach ($generators as $generator){
|
|
| 298 | + foreach ($generators as $generator) {
|
|
| 299 | 299 | |
| 300 | 300 | //generator method name |
| 301 | 301 | $generatorMethodName = $generator.'Generator'; |
| 302 | 302 | |
| 303 | 303 | // if the generator method is present, |
| 304 | 304 | // the fake value is assigned. |
| 305 | - if(method_exists($this,$generatorMethodName)){
|
|
| 305 | + if (method_exists($this, $generatorMethodName)) {
|
|
| 306 | 306 | |
| 307 | 307 | //fake registration |
| 308 | - if(!isset($this->inputs[$generator])){
|
|
| 308 | + if (!isset($this->inputs[$generator])) {
|
|
| 309 | 309 | |
| 310 | 310 | $generatorMethodNameResult = $this->{$generatorMethodName}();
|
| 311 | 311 | |
| 312 | - if(!is_null($generatorMethodNameResult)){
|
|
| 312 | + if (!is_null($generatorMethodNameResult)) {
|
|
| 313 | 313 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 314 | 314 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 315 | 315 | $this->generatorList[] = $generator; |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | else {
|
| 319 | 319 | |
| 320 | - if($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 321 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
|
| 320 | + if ($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 321 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) {
|
|
| 322 | 322 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 323 | 323 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 324 | 324 | $this->generatorList[] = $generator; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if($this->checkProperties('generators_dont_overwrite')
|
|
| 328 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){
|
|
| 327 | + if ($this->checkProperties('generators_dont_overwrite')
|
|
| 328 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) {
|
|
| 329 | 329 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 330 | 330 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 331 | 331 | $this->generatorList[] = $generator; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | {
|
| 403 | 403 | // we use the http method to write |
| 404 | 404 | // the values to the inputs and origin properties. |
| 405 | - foreach($this->clientData as $key=>$value){
|
|
| 405 | + foreach ($this->clientData as $key=>$value) {
|
|
| 406 | 406 | |
| 407 | 407 | //inputs and origin properties |
| 408 | 408 | $this->inputs[$key] = $value; |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | private function requestExcept() |
| 420 | 420 | {
|
| 421 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){
|
|
| 422 | - foreach ($this->requestExcept as $item){
|
|
| 423 | - if(isset($this->inputs[$item])){
|
|
| 421 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) {
|
|
| 422 | + foreach ($this->requestExcept as $item) {
|
|
| 423 | + if (isset($this->inputs[$item])) {
|
|
| 424 | 424 | unset($this->inputs[$item]); |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -433,16 +433,16 @@ discard block |
||
| 433 | 433 | * @param null|string $clientName |
| 434 | 434 | * @return void|mixed |
| 435 | 435 | */ |
| 436 | - public function setClientName($clientName=null) |
|
| 436 | + public function setClientName($clientName = null) |
|
| 437 | 437 | {
|
| 438 | - if(!is_null($clientName) && is_string($clientName)){
|
|
| 438 | + if (!is_null($clientName) && is_string($clientName)) {
|
|
| 439 | 439 | return $this->clientName = $clientName; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){
|
|
| 442 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) {
|
|
| 443 | 443 | $backTrace = Utils::trace(0)['object']; |
| 444 | 444 | |
| 445 | - if(property_exists($backTrace,'clientName')){
|
|
| 445 | + if (property_exists($backTrace, 'clientName')) {
|
|
| 446 | 446 | $this->clientName = $backTrace->clientName; |
| 447 | 447 | } |
| 448 | 448 | } |
@@ -459,12 +459,12 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | // we update the input values after |
| 461 | 461 | // we receive and check the saved objects. |
| 462 | - foreach ($clientObjects as $key=>$value){
|
|
| 462 | + foreach ($clientObjects as $key=>$value) {
|
|
| 463 | 463 | |
| 464 | - if(property_exists($this,'groups') && is_array($this->groups)){
|
|
| 464 | + if (property_exists($this, 'groups') && is_array($this->groups)) {
|
|
| 465 | 465 | |
| 466 | - foreach ($this->groups as $group){
|
|
| 467 | - if(isset($clientObjects['origin'][$group][$key])){
|
|
| 466 | + foreach ($this->groups as $group) {
|
|
| 467 | + if (isset($clientObjects['origin'][$group][$key])) {
|
|
| 468 | 468 | $this->{$key} = $clientObjects['origin'][$group][$key];
|
| 469 | 469 | $this->inputs[$key] = $this->{$key};
|
| 470 | 470 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){
|
|
| 479 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) {
|
|
| 480 | 480 | |
| 481 | 481 | $this->{$key} = $clientObjects['origin'][$key];
|
| 482 | 482 | $this->inputs[$key] = $this->{$key};
|
@@ -504,11 +504,11 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | // the request update to be performed using |
| 506 | 506 | // the method name to be used with the http method. |
| 507 | - $this->setRequestInputs($requestMethod,$key); |
|
| 507 | + $this->setRequestInputs($requestMethod, $key); |
|
| 508 | 508 | |
| 509 | 509 | // the request update to be performed using |
| 510 | 510 | // the method name to be used without the http method. |
| 511 | - $this->setRequestInputs($key,$key); |
|
| 511 | + $this->setRequestInputs($key, $key); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -519,28 +519,28 @@ discard block |
||
| 519 | 519 | * |
| 520 | 520 | * @throws ReflectionExceptionAlias |
| 521 | 521 | */ |
| 522 | - private function setRequestInputs($method,$key) |
|
| 522 | + private function setRequestInputs($method, $key) |
|
| 523 | 523 | {
|
| 524 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
|
|
| 524 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
|
|
| 525 | 525 | |
| 526 | 526 | //check annotations for method |
| 527 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
| 528 | - $annotation->annotation($method,$key); |
|
| 527 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
| 528 | + $annotation->annotation($method, $key); |
|
| 529 | 529 | |
| 530 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
|
|
| 530 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
|
|
| 531 | 531 | |
| 532 | 532 | $inputKeys = $this->inputs[$key]; |
| 533 | 533 | |
| 534 | 534 | $this->inputs[$key] = []; |
| 535 | - foreach ($inputKeys as $input){
|
|
| 535 | + foreach ($inputKeys as $input) {
|
|
| 536 | 536 | |
| 537 | 537 | $this->{$key} = $input;
|
| 538 | 538 | $keyMethod = $this->{$method}();
|
| 539 | 539 | $this->inputs[$key][] = $keyMethod; |
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | - else{
|
|
| 543 | - if(isset($this->inputs[$key])){
|
|
| 542 | + else {
|
|
| 543 | + if (isset($this->inputs[$key])) {
|
|
| 544 | 544 | $keyMethod = $this->{$method}();
|
| 545 | 545 | $this->inputs[$key] = $keyMethod; |
| 546 | 546 | } |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | // the auto object validate property is the property |
| 560 | 560 | // where all of your request values are automatically validated. |
| 561 | 561 | /** @noinspection PhpParamsInspection */ |
| 562 | - if(property_exists($this,'autoObjectValidate') |
|
| 563 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
|
|
| 562 | + if (property_exists($this, 'autoObjectValidate') |
|
| 563 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
|
|
| 564 | 564 | $this->autoValidate('autoObjectValidate');
|
| 565 | 565 | } |
| 566 | 566 | } |