@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param $key |
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | - abstract function annotation($method,$key); |
|
25 | + abstract function annotation($method, $key); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * get input values from request object |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param $reflection |
54 | 54 | */ |
55 | - public function setReflection($reflection){ |
|
55 | + public function setReflection($reflection) { |
|
56 | 56 | |
57 | 57 | $this->request = ClosureDispatcher::bind($reflection); |
58 | 58 | } |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | //catch exception |
70 | 70 | exception($this->exceptionParams[$key]['name'],$keyParams) |
71 | 71 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
72 | - } |
|
73 | - else{ |
|
72 | + } else{ |
|
74 | 73 | //catch exception |
75 | 74 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
76 | 75 | } |
@@ -128,8 +127,7 @@ discard block |
||
128 | 127 | $this->catchException($key,$regex[1]); |
129 | 128 | } |
130 | 129 | } |
131 | - } |
|
132 | - else{ |
|
130 | + } else{ |
|
133 | 131 | |
134 | 132 | // we control the regex rule that evaluates when only string arrives. |
135 | 133 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){ |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param ApplicationContracts $app |
22 | 22 | * @param $request |
23 | 23 | */ |
24 | - public function __construct(ApplicationContracts $app,$request) |
|
24 | + public function __construct(ApplicationContracts $app, $request) |
|
25 | 25 | { |
26 | 26 | parent::__construct($app); |
27 | 27 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param $key |
38 | 38 | * @return mixed|void |
39 | 39 | */ |
40 | - public function annotation($method,$key) |
|
40 | + public function annotation($method, $key) |
|
41 | 41 | { |
42 | 42 | //set annotation value with getting reflection |
43 | 43 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method); |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | * @param string $key |
63 | 63 | * @param null|string $data |
64 | 64 | */ |
65 | - private function catchException($key,$data) |
|
65 | + private function catchException($key, $data) |
|
66 | 66 | { |
67 | - if(isset($this->exceptionParams[$key])){ |
|
67 | + if (isset($this->exceptionParams[$key])) { |
|
68 | 68 | |
69 | 69 | //get key params for exception params |
70 | 70 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
71 | 71 | |
72 | 72 | //catch exception |
73 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
73 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
74 | 74 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
75 | 75 | } |
76 | - else{ |
|
76 | + else { |
|
77 | 77 | //catch exception |
78 | 78 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
79 | 79 | } |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function getException($key) |
88 | 88 | { |
89 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){ |
|
89 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) { |
|
90 | 90 | |
91 | - $exceptionSpaceExplode = explode(" ",$exception[1]); |
|
91 | + $exceptionSpaceExplode = explode(" ", $exception[1]); |
|
92 | 92 | |
93 | - foreach ($exceptionSpaceExplode as $exceptions){ |
|
94 | - $exceptionsDotExplode = explode(":",$exceptions); |
|
93 | + foreach ($exceptionSpaceExplode as $exceptions) { |
|
94 | + $exceptionsDotExplode = explode(":", $exceptions); |
|
95 | 95 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
96 | 96 | } |
97 | 97 | |
98 | - if(isset($this->exceptionParams[$key]['params'])){ |
|
98 | + if (isset($this->exceptionParams[$key]['params'])) { |
|
99 | 99 | |
100 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']); |
|
100 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']); |
|
101 | 101 | unset($this->exceptionParams[$key]['params']); |
102 | 102 | |
103 | - foreach ($paramsCommaExplode as $params){ |
|
104 | - $paramsEqualExplode = explode("=",$params); |
|
105 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){ |
|
103 | + foreach ($paramsCommaExplode as $params) { |
|
104 | + $paramsEqualExplode = explode("=", $params); |
|
105 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) { |
|
106 | 106 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
107 | 107 | } |
108 | 108 | } |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | { |
120 | 120 | // with the method based regex annotation, |
121 | 121 | // we check the rule definition for our requests. |
122 | - if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){ |
|
123 | - if(isset($this->inputs[$key])){ |
|
122 | + if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) { |
|
123 | + if (isset($this->inputs[$key])) { |
|
124 | 124 | |
125 | 125 | // for the definition of rules, |
126 | 126 | // our inputs can be array and in this case we offer array option for user comfort. |
127 | - if(is_array($this->inputs[$key])){ |
|
127 | + if (is_array($this->inputs[$key])) { |
|
128 | 128 | |
129 | - foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){ |
|
130 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){ |
|
131 | - $this->catchException($key,$regex[1]); |
|
129 | + foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) { |
|
130 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) { |
|
131 | + $this->catchException($key, $regex[1]); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | - else{ |
|
135 | + else { |
|
136 | 136 | |
137 | 137 | // we control the regex rule that evaluates when only string arrives. |
138 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){ |
|
139 | - $this->catchException($key,$regex[1]); |
|
138 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) { |
|
139 | + $this->catchException($key, $regex[1]); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | */ |
152 | 152 | private function getRemove($key) |
153 | 153 | { |
154 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){ |
|
155 | - if(isset($this->inputs[$key])){ |
|
156 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){ |
|
154 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) { |
|
155 | + if (isset($this->inputs[$key])) { |
|
156 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) { |
|
157 | 157 | unset($this->inputs[$key]); |
158 | 158 | } |
159 | 159 | } |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function getRules($key) |
169 | 169 | { |
170 | - if(preg_match('@rule\((.*?)\)\r\n@is',$this->annotation,$rule)){ |
|
170 | + if (preg_match('@rule\((.*?)\)\r\n@is', $this->annotation, $rule)) { |
|
171 | 171 | |
172 | 172 | $requestRules = $this->getReflection('rules'); |
173 | 173 | |
174 | - $rules = explode(":",$rule[1]); |
|
175 | - if(isset($this->inputs[$key])){ |
|
176 | - foreach($rules as $rule){ |
|
177 | - if(isset($requestRules[$rule])){ |
|
178 | - if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){ |
|
179 | - exception($rule,['key'=>$key]) |
|
174 | + $rules = explode(":", $rule[1]); |
|
175 | + if (isset($this->inputs[$key])) { |
|
176 | + foreach ($rules as $rule) { |
|
177 | + if (isset($requestRules[$rule])) { |
|
178 | + if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) { |
|
179 | + exception($rule, ['key'=>$key]) |
|
180 | 180 | ->invalidArgument($key.' input value is not valid for '.$rule.' request rule'); |
181 | 181 | } |
182 | 182 | } |
@@ -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; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @throws ReflectionExceptionAlias |
43 | 43 | */ |
44 | - public function __construct($clientData=null) |
|
44 | + public function __construct($clientData = null) |
|
45 | 45 | { |
46 | 46 | //reflection process |
47 | 47 | $this->reflection = app()['reflection']($this); |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | private function autoValidate($validate) |
65 | 65 | { |
66 | 66 | //we get the values to auto-validate. |
67 | - foreach ($this->{$validate} as $object=>$datas){ |
|
67 | + foreach ($this->{$validate} as $object=>$datas) { |
|
68 | 68 | |
69 | 69 | // the auto-validate value must necessarily represent a class. |
70 | 70 | // otherwise auto-validate is not used. |
71 | - if(Utils::isNamespaceExists($object)){ |
|
71 | + if (Utils::isNamespaceExists($object)) { |
|
72 | 72 | $getObjectInstance = app()->resolve($object); |
73 | 73 | |
74 | 74 | // we get the index values, |
75 | 75 | // which are called methods of the auto-validate value that represents the class. |
76 | - foreach ($datas as $dataKey=>$data){ |
|
76 | + foreach ($datas as $dataKey=>$data) { |
|
77 | 77 | |
78 | 78 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
79 | 79 | // the process of auto-validate automatic implementation will be completed. |
80 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){ |
|
81 | - if(isset($this->origin[$data])){ |
|
82 | - if(!is_array($this->origin[$data])){ |
|
80 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) { |
|
81 | + if (isset($this->origin[$data])) { |
|
82 | + if (!is_array($this->origin[$data])) { |
|
83 | 83 | $this->origin[$data] = array($this->origin[$data]); |
84 | 84 | } |
85 | - foreach ($this->origin[$data] as $originData){ |
|
85 | + foreach ($this->origin[$data] as $originData) { |
|
86 | 86 | $getObjectInstance->{$data}($originData); |
87 | 87 | } |
88 | 88 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | { |
102 | 102 | // expected method is executed. |
103 | 103 | // this method is a must for http method values to be found in this property. |
104 | - if($this->checkProperties('capsule')){ |
|
105 | - foreach($this->inputs as $input=>$value){ |
|
106 | - if(!in_array($input,$this->capsule)){ |
|
104 | + if ($this->checkProperties('capsule')) { |
|
105 | + foreach ($this->inputs as $input=>$value) { |
|
106 | + if (!in_array($input, $this->capsule)) { |
|
107 | 107 | exception('capsuleRequestException')->overflow('The '.$input.' value cannot be sent.'); |
108 | 108 | } |
109 | 109 | } |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | |
123 | 123 | // Determines which HTTP method |
124 | 124 | // the request object will be exposed to. |
125 | - if($this->checkProperties('http')){ |
|
125 | + if ($this->checkProperties('http')) { |
|
126 | 126 | |
127 | 127 | // if the current http method does not exist |
128 | 128 | // in the http object, the exception will be thrown. |
129 | - if(!in_array($method,$this->http)){ |
|
129 | + if (!in_array($method, $this->http)) { |
|
130 | 130 | |
131 | 131 | //exception batMethodCall |
132 | 132 | exception()->badMethodCall( |
133 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
133 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | // from the properties of the object properties to |
147 | 147 | // the existing variables, control the array and at least one element. |
148 | - return (property_exists($this,$properties) |
|
148 | + return (property_exists($this, $properties) |
|
149 | 149 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
150 | 150 | } |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | // we are saving the expected values for the request in container. |
160 | 160 | // this record can be returned in exception information. |
161 | - app()->register('requestExpected',$this->expected); |
|
161 | + app()->register('requestExpected', $this->expected); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | public function except($except) |
171 | 171 | { |
172 | 172 | // the except parameter is a callable value. |
173 | - if(is_callable($except)){ |
|
174 | - $call = call_user_func_array($except,[$this]); |
|
173 | + if (is_callable($except)) { |
|
174 | + $call = call_user_func_array($except, [$this]); |
|
175 | 175 | $except = $call; |
176 | 176 | } |
177 | 177 | |
178 | 178 | // except with the except exceptions property |
179 | 179 | // and then assigning them to the inputs property. |
180 | - $this->except = array_merge($this->except,$except); |
|
181 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
180 | + $this->except = array_merge($this->except, $except); |
|
181 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
182 | 182 | |
183 | 183 | return $this; |
184 | 184 | } |
@@ -192,27 +192,27 @@ discard block |
||
192 | 192 | { |
193 | 193 | // expected method is executed. |
194 | 194 | // this method is a must for http method values to be found in this property. |
195 | - if($this->checkProperties('expected')){ |
|
195 | + if ($this->checkProperties('expected')) { |
|
196 | 196 | |
197 | 197 | // if the expected values are not found in the inputs array, |
198 | 198 | // the exception will be thrown. |
199 | - foreach ($this->expected as $expected){ |
|
199 | + foreach ($this->expected as $expected) { |
|
200 | 200 | |
201 | 201 | $expectedValues = []; |
202 | 202 | |
203 | 203 | // mandatory expected data for each key can be separated by | operator. |
204 | 204 | // this is evaluated as "or". |
205 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
206 | - if(!isset($this->inputs[$inputs])){ |
|
205 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
206 | + if (!isset($this->inputs[$inputs])) { |
|
207 | 207 | $expectedValues[] = $inputs; |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | // if the expectedData and expectedValues |
212 | 212 | // array are numerically equal to the expected key, the exception is thrown. |
213 | - if(count($expectedData)===count($expectedValues)){ |
|
213 | + if (count($expectedData)===count($expectedValues)) { |
|
214 | 214 | exception($expected) |
215 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
215 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | { |
228 | 228 | // check the presence of the generator object |
229 | 229 | // and operate the generator over this object. |
230 | - if($this->checkProperties('auto_generators')){ |
|
230 | + if ($this->checkProperties('auto_generators')) { |
|
231 | 231 | $generators = $this->getAutoGenerators(); |
232 | 232 | } |
233 | 233 | |
234 | 234 | // check the presence of the generator object |
235 | 235 | // and operate the generator over this object. |
236 | - if($this->checkProperties('generators')){ |
|
237 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
236 | + if ($this->checkProperties('generators')) { |
|
237 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
238 | 238 | } |
239 | 239 | |
240 | - if(isset($generators)){ |
|
240 | + if (isset($generators)) { |
|
241 | 241 | $this->generatorMethod($generators); |
242 | 242 | } |
243 | 243 | } |
@@ -252,30 +252,30 @@ discard block |
||
252 | 252 | private function generatorMethod($generators) |
253 | 253 | { |
254 | 254 | //generator array object |
255 | - foreach ($generators as $generator){ |
|
255 | + foreach ($generators as $generator) { |
|
256 | 256 | |
257 | 257 | //generator method name |
258 | 258 | $generatorMethodName = $generator.'Generator'; |
259 | 259 | |
260 | 260 | // if the generator method is present, |
261 | 261 | // the fake value is assigned. |
262 | - if(method_exists($this,$generatorMethodName)){ |
|
262 | + if (method_exists($this, $generatorMethodName)) { |
|
263 | 263 | |
264 | 264 | //fake registration |
265 | - if(!isset($this->inputs[$generator])){ |
|
265 | + if (!isset($this->inputs[$generator])) { |
|
266 | 266 | $this->{$generator} = $this->{$generatorMethodName}(); |
267 | 267 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
268 | 268 | } |
269 | 269 | else { |
270 | 270 | |
271 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
272 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
271 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
272 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
273 | 273 | $this->{$generator} = $this->{$generatorMethodName}(); |
274 | 274 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
275 | 275 | } |
276 | 276 | |
277 | - if($this->checkProperties('generators_dont_overwrite') |
|
278 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
277 | + if ($this->checkProperties('generators_dont_overwrite') |
|
278 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
279 | 279 | $this->{$generator} = $this->{$generatorMethodName}(); |
280 | 280 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
281 | 281 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | // we use the http method to write |
324 | 324 | // the values to the inputs and origin properties. |
325 | - foreach($this->clientData as $key=>$value){ |
|
325 | + foreach ($this->clientData as $key=>$value) { |
|
326 | 326 | |
327 | 327 | //inputs and origin properties |
328 | 328 | $this->inputs[$key] = $value; |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | |
370 | 370 | // we update the input values after |
371 | 371 | // we receive and check the saved objects. |
372 | - foreach ($clientObjects as $key=>$value){ |
|
372 | + foreach ($clientObjects as $key=>$value) { |
|
373 | 373 | |
374 | - if(isset($clientObjects['origin'][$key])){ |
|
374 | + if (isset($clientObjects['origin'][$key])) { |
|
375 | 375 | |
376 | 376 | $this->{$key} = $clientObjects['origin'][$key]; |
377 | 377 | $this->inputs[$key] = $this->{$key}; |
@@ -398,11 +398,11 @@ discard block |
||
398 | 398 | |
399 | 399 | // the request update to be performed using |
400 | 400 | // the method name to be used with the http method. |
401 | - $this->setRequestInputs($requestMethod,$key); |
|
401 | + $this->setRequestInputs($requestMethod, $key); |
|
402 | 402 | |
403 | 403 | // the request update to be performed using |
404 | 404 | // the method name to be used without the http method. |
405 | - $this->setRequestInputs($key,$key); |
|
405 | + $this->setRequestInputs($key, $key); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -413,28 +413,28 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @throws ReflectionExceptionAlias |
415 | 415 | */ |
416 | - private function setRequestInputs($method,$key) |
|
416 | + private function setRequestInputs($method, $key) |
|
417 | 417 | { |
418 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
418 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
419 | 419 | |
420 | 420 | //check annotations for method |
421 | - $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]); |
|
422 | - $annotation->annotation($method,$key); |
|
421 | + $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]); |
|
422 | + $annotation->annotation($method, $key); |
|
423 | 423 | |
424 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
424 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
425 | 425 | |
426 | 426 | $inputKeys = $this->inputs[$key]; |
427 | 427 | |
428 | 428 | $this->inputs[$key] = []; |
429 | - foreach ($inputKeys as $input){ |
|
429 | + foreach ($inputKeys as $input) { |
|
430 | 430 | |
431 | 431 | $this->{$key} = $input; |
432 | 432 | $keyMethod = $this->{$method}(); |
433 | 433 | $this->inputs[$key][] = $keyMethod; |
434 | 434 | } |
435 | 435 | } |
436 | - else{ |
|
437 | - if(isset($this->inputs[$key])){ |
|
436 | + else { |
|
437 | + if (isset($this->inputs[$key])) { |
|
438 | 438 | $keyMethod = $this->{$method}(); |
439 | 439 | $this->inputs[$key] = $keyMethod; |
440 | 440 | } |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | { |
453 | 453 | // the auto object validate property is the property |
454 | 454 | // where all of your request values are automatically validated. |
455 | - if(property_exists($this,'autoObjectValidate') |
|
456 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
455 | + if (property_exists($this, 'autoObjectValidate') |
|
456 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
457 | 457 | $this->autoValidate('autoObjectValidate'); |
458 | 458 | } |
459 | 459 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function getAutoGenerators() |
33 | 33 | { |
34 | - if(property_exists($this,'auto_generators')){ |
|
34 | + if (property_exists($this, 'auto_generators')) { |
|
35 | 35 | return $this->auto_generators; |
36 | 36 | } |
37 | 37 | return []; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function getAutoGeneratorsDontOverwrite() |
47 | 47 | { |
48 | - if(property_exists($this,'auto_generators_dont_overwrite')){ |
|
48 | + if (property_exists($this, 'auto_generators_dont_overwrite')) { |
|
49 | 49 | return $this->auto_generators_dont_overwrite; |
50 | 50 | } |
51 | 51 | return []; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function getClientObjects() |
61 | 61 | { |
62 | - return array_diff_key($this->getObjects(),['inputs'=>[]]); |
|
62 | + return array_diff_key($this->getObjects(), ['inputs'=>[]]); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function getGenerators() |
71 | 71 | { |
72 | - if(property_exists($this,'generators')){ |
|
72 | + if (property_exists($this, 'generators')) { |
|
73 | 73 | return $this->generators; |
74 | 74 | } |
75 | 75 | return []; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function getGeneratorsDontOverwrite() |
85 | 85 | { |
86 | - if(property_exists($this,'generators_dont_overwrite')){ |
|
86 | + if (property_exists($this, 'generators_dont_overwrite')) { |
|
87 | 87 | return $this->generators_dont_overwrite; |
88 | 88 | } |
89 | 89 | return []; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var array |
34 | 34 | */ |
35 | - public $commandRule=['helper']; |
|
35 | + public $commandRule = ['helper']; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @return mixed |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | public function create() |
41 | 41 | { |
42 | 42 | |
43 | - if(!file_exists(app()->path()->helpers())){ |
|
44 | - $this->directory['helper'] = app()->path()->helpers(); |
|
43 | + if (!file_exists(app()->path()->helpers())) { |
|
44 | + $this->directory['helper'] = app()->path()->helpers(); |
|
45 | 45 | $this->file->makeDirectory($this); |
46 | 46 | } |
47 | 47 | |
48 | - $this->touch['helpers/general']= app()->path()->helpers().'/'.ucfirst($this->argument['helper']).'.php'; |
|
48 | + $this->touch['helpers/general'] = app()->path()->helpers().'/'.ucfirst($this->argument['helper']).'.php'; |
|
49 | 49 | |
50 | 50 | |
51 | 51 | $this->file->touch($this); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param $document |
24 | 24 | * @param array $class |
25 | 25 | */ |
26 | - public function __construct($app,$document,$class=array()) |
|
26 | + public function __construct($app, $document, $class = array()) |
|
27 | 27 | { |
28 | 28 | parent::__construct($app); |
29 | 29 | |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | |
47 | 47 | // if you have information about cache in |
48 | 48 | // the document section of the method, the cache process is executed. |
49 | - if(is_string($this->document) && preg_match('#@cache\((.*?)\)\r\n#is',$this->document,$cache)){ |
|
49 | + if (is_string($this->document) && preg_match('#@cache\((.*?)\)\r\n#is', $this->document, $cache)) { |
|
50 | 50 | |
51 | 51 | // if the cache information |
52 | 52 | // with regular expression does not contain null data. |
53 | - if($cache!==null && isset($cache[1])){ |
|
53 | + if ($cache!==null && isset($cache[1])) { |
|
54 | 54 | |
55 | 55 | //as static we inject the name value into the cache data. |
56 | 56 | $cacheData = ['cache'=>['name'=>Utils::encryptArrayData($this->class)]]; |
57 | 57 | |
58 | 58 | //cache data with the help of foreach data are transferred into the cache. |
59 | - foreach(array_filter(explode(" ",$cache[1]),'strlen') as $item){ |
|
59 | + foreach (array_filter(explode(" ", $cache[1]), 'strlen') as $item) { |
|
60 | 60 | |
61 | - $items = explode("=",$item); |
|
61 | + $items = explode("=", $item); |
|
62 | 62 | $cacheData['cache'][$items[0]] = $items[1]; |
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | //we save the data stored in the cacheData variable as methodCache. |
68 | - $this->app->register('containerReflection','methodCache',$cacheData); |
|
68 | + $this->app->register('containerReflection', 'methodCache', $cacheData); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @throws \DI\DependencyException |
23 | 23 | * @throws \DI\NotFoundException |
24 | 24 | */ |
25 | - public static function resolve($class=null) |
|
25 | + public static function resolve($class = null) |
|
26 | 26 | { |
27 | 27 | //class resolve |
28 | - if(!is_null($class)){ |
|
28 | + if (!is_null($class)) { |
|
29 | 29 | $container = self::callBuild(); |
30 | 30 | return $container->get($class); |
31 | 31 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * @throws \DI\DependencyException |
42 | 42 | * @throws \DI\NotFoundException |
43 | 43 | */ |
44 | - public static function make($class=null, $param=array()) |
|
44 | + public static function make($class = null, $param = array()) |
|
45 | 45 | { |
46 | - if($class!==null){ |
|
46 | + if ($class!==null) { |
|
47 | 47 | |
48 | 48 | $container = self::callBuild(); |
49 | - return $container->make($class,$param); |
|
49 | + return $container->make($class, $param); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | return null; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @throws \DI\DependencyException |
60 | 60 | */ |
61 | - public static function injectOnBind($class=null) |
|
61 | + public static function injectOnBind($class = null) |
|
62 | 62 | { |
63 | - if($class!==null){ |
|
63 | + if ($class!==null) { |
|
64 | 64 | |
65 | 65 | $container = self::callBuild(); |
66 | 66 | return $container->injectOn($class); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param array $param |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public static function callBind($class=null, $param=array()) |
|
77 | + public static function callBind($class = null, $param = array()) |
|
78 | 78 | { |
79 | - return (app()->resolve(ContainerResolve::class))->call($class,$param,function($call){ |
|
80 | - return self::callBuild()->call($call->class,$call->param); |
|
79 | + return (app()->resolve(ContainerResolve::class))->call($class, $param, function($call) { |
|
80 | + return self::callBuild()->call($call->class, $call->param); |
|
81 | 81 | }); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -9,23 +9,23 @@ |
||
9 | 9 | * @param $param |
10 | 10 | * @return mixed |
11 | 11 | */ |
12 | - public function handle($parameter,$param) |
|
12 | + public function handle($parameter, $param) |
|
13 | 13 | { |
14 | 14 | // We will use a custom bind for the repository classes |
15 | 15 | // and bind the repository contract with the repository adapter class. |
16 | 16 | $parameterName = $parameter->getType()->getName(); |
17 | 17 | $repository = app()->namespace()->repository(); |
18 | 18 | |
19 | - $parameterNameWord = str_replace('\\','',$parameterName); |
|
20 | - $repositoryWord = str_replace('\\','',$repository); |
|
19 | + $parameterNameWord = str_replace('\\', '', $parameterName); |
|
20 | + $repositoryWord = str_replace('\\', '', $repository); |
|
21 | 21 | |
22 | 22 | |
23 | 23 | // if the submitted contract matches the repository class. |
24 | - if(preg_match('@'.$repositoryWord.'@is',$parameterNameWord)){ |
|
24 | + if (preg_match('@'.$repositoryWord.'@is', $parameterNameWord)) { |
|
25 | 25 | |
26 | 26 | //we bind the contract as an adapter |
27 | - $repositoryName = str_replace('Contract','',$parameter->getName()); |
|
28 | - $getRepositoryAdapter = app()->get('appClass')::repository($repositoryName,true); |
|
27 | + $repositoryName = str_replace('Contract', '', $parameter->getName()); |
|
28 | + $getRepositoryAdapter = app()->get('appClass')::repository($repositoryName, true); |
|
29 | 29 | |
30 | 30 | $param[$parameter->getName()] = app()->resolve($getRepositoryAdapter)->adapter(); |
31 | 31 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @var $type |
15 | 15 | */ |
16 | - public $type='token'; |
|
16 | + public $type = 'token'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @var array |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var $commandRule |
32 | 32 | */ |
33 | - public $commandRule=['key']; |
|
33 | + public $commandRule = ['key']; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @return void |
37 | 37 | */ |
38 | - public function create(){ |
|
38 | + public function create() { |
|
39 | 39 | |
40 | 40 | // |
41 | 41 | $clientApiToken = StaticPathModel::appMiddlewarePath($this->projectName()).'\\ClientApiToken'; |
42 | 42 | $resolveClientApiToken = app()->resolve($clientApiToken); |
43 | 43 | |
44 | 44 | // |
45 | - $key=lcfirst($this->argument['key']); |
|
45 | + $key = lcfirst($this->argument['key']); |
|
46 | 46 | |
47 | 47 | echo $this->info($resolveClientApiToken->createToken($key)); |
48 | 48 | } |