@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @throws ReflectionExceptionAlias |
| 58 | 58 | */ |
| 59 | - public function __construct($clientData=null) |
|
| 59 | + public function __construct($clientData = null) |
|
| 60 | 60 | {
|
| 61 | 61 | //reflection process |
| 62 | 62 | $this->reflection = app()['reflection']($this); |
@@ -79,25 +79,25 @@ discard block |
||
| 79 | 79 | private function autoValidate($validate) |
| 80 | 80 | {
|
| 81 | 81 | //we get the values ββto auto-validate. |
| 82 | - foreach ($this->{$validate} as $object=>$datas){
|
|
| 82 | + foreach ($this->{$validate} as $object=>$datas) {
|
|
| 83 | 83 | |
| 84 | 84 | // the auto-validate value must necessarily represent a class. |
| 85 | 85 | // otherwise auto-validate is not used. |
| 86 | - if(Utils::isNamespaceExists($object)){
|
|
| 86 | + if (Utils::isNamespaceExists($object)) {
|
|
| 87 | 87 | $getObjectInstance = app()->resolve($object); |
| 88 | 88 | |
| 89 | 89 | // we get the index values, |
| 90 | 90 | // which are called methods of the auto-validate value that represents the class. |
| 91 | - foreach ($datas as $dataKey=>$data){
|
|
| 91 | + foreach ($datas as $dataKey=>$data) {
|
|
| 92 | 92 | |
| 93 | 93 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
| 94 | 94 | // the process of auto-validate automatic implementation will be completed. |
| 95 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
|
|
| 96 | - if(isset($this->origin[$data])){
|
|
| 97 | - if(!is_array($this->origin[$data])){
|
|
| 95 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
|
|
| 96 | + if (isset($this->origin[$data])) {
|
|
| 97 | + if (!is_array($this->origin[$data])) {
|
|
| 98 | 98 | $this->origin[$data] = array($this->origin[$data]); |
| 99 | 99 | } |
| 100 | - foreach ($this->origin[$data] as $originData){
|
|
| 100 | + foreach ($this->origin[$data] as $originData) {
|
|
| 101 | 101 | $getObjectInstance->{$data}($originData);
|
| 102 | 102 | } |
| 103 | 103 | } |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | {
|
| 117 | 117 | // expected method is executed. |
| 118 | 118 | // this method is a must for http method values to be found in this property. |
| 119 | - if($this->checkProperties('capsule')){
|
|
| 119 | + if ($this->checkProperties('capsule')) {
|
|
| 120 | 120 | |
| 121 | 121 | $caret = $this->capsuleCaret(); |
| 122 | 122 | |
| 123 | - foreach($this->inputs as $input=>$value){
|
|
| 123 | + foreach ($this->inputs as $input=>$value) {
|
|
| 124 | 124 | |
| 125 | - if(isset($caret[$input]) || ( |
|
| 126 | - $this->checkProperties('capsule') && !in_array($input,$this->capsule)
|
|
| 127 | - )){
|
|
| 125 | + if (isset($caret[$input]) || ( |
|
| 126 | + $this->checkProperties('capsule') && !in_array($input, $this->capsule)
|
|
| 127 | + )) {
|
|
| 128 | 128 | exception('capsuleRequestException')
|
| 129 | 129 | ->overflow('The '.$input.' value cannot be sent.');
|
| 130 | 130 | } |
@@ -141,15 +141,15 @@ discard block |
||
| 141 | 141 | {
|
| 142 | 142 | $caret = []; |
| 143 | 143 | |
| 144 | - foreach($this->inputs as $input=>$item){
|
|
| 145 | - if(in_array('@'.$input,$this->capsule)){
|
|
| 144 | + foreach ($this->inputs as $input=>$item) {
|
|
| 145 | + if (in_array('@'.$input, $this->capsule)) {
|
|
| 146 | 146 | $caret[$input] = $item; |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | foreach ($this->capsule as $item) {
|
| 151 | - if(preg_match('#@.*#is',$item)){
|
|
| 152 | - $this->capsule = array_diff($this->capsule,[$item]); |
|
| 151 | + if (preg_match('#@.*#is', $item)) {
|
|
| 152 | + $this->capsule = array_diff($this->capsule, [$item]); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -168,15 +168,15 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // Determines which HTTP method |
| 170 | 170 | // the request object will be exposed to. |
| 171 | - if($this->checkProperties('http')){
|
|
| 171 | + if ($this->checkProperties('http')) {
|
|
| 172 | 172 | |
| 173 | 173 | // if the current http method does not exist |
| 174 | 174 | // in the http object, the exception will be thrown. |
| 175 | - if(!in_array($method,$this->http)){
|
|
| 175 | + if (!in_array($method, $this->http)) {
|
|
| 176 | 176 | |
| 177 | 177 | //exception batMethodCall |
| 178 | 178 | exception()->badMethodCall( |
| 179 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
|
|
| 179 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
|
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | {
|
| 192 | 192 | // from the properties of the object properties to |
| 193 | 193 | // the existing variables, control the array and at least one element. |
| 194 | - return (property_exists($this,$properties) |
|
| 194 | + return (property_exists($this, $properties) |
|
| 195 | 195 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
|
| 196 | 196 | } |
| 197 | 197 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | {
|
| 205 | 205 | // we are saving the expected values ββfor the request in container. |
| 206 | 206 | // this record can be returned in exception information. |
| 207 | - app()->register('requestExpected',$this->expected);
|
|
| 207 | + app()->register('requestExpected', $this->expected);
|
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | public function except($except) |
| 217 | 217 | {
|
| 218 | 218 | // the except parameter is a callable value. |
| 219 | - if(is_callable($except)){
|
|
| 220 | - $call = call_user_func_array($except,[$this]); |
|
| 219 | + if (is_callable($except)) {
|
|
| 220 | + $call = call_user_func_array($except, [$this]); |
|
| 221 | 221 | $except = $call; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // except with the except exceptions property |
| 225 | 225 | // and then assigning them to the inputs property. |
| 226 | - $this->except = array_merge($this->except,$except); |
|
| 227 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
| 226 | + $this->except = array_merge($this->except, $except); |
|
| 227 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
| 228 | 228 | |
| 229 | 229 | return $this; |
| 230 | 230 | } |
@@ -238,27 +238,27 @@ discard block |
||
| 238 | 238 | {
|
| 239 | 239 | // expected method is executed. |
| 240 | 240 | // this method is a must for http method values to be found in this property. |
| 241 | - if($this->checkProperties('expected')){
|
|
| 241 | + if ($this->checkProperties('expected')) {
|
|
| 242 | 242 | |
| 243 | 243 | // if the expected values are not found in the inputs array, |
| 244 | 244 | // the exception will be thrown. |
| 245 | - foreach ($this->expected as $expected){
|
|
| 245 | + foreach ($this->expected as $expected) {
|
|
| 246 | 246 | |
| 247 | 247 | $expectedValues = []; |
| 248 | 248 | |
| 249 | 249 | // mandatory expected data for each key can be separated by | operator. |
| 250 | 250 | // this is evaluated as "or". |
| 251 | - foreach($expectedData = explode("|",$expected) as $inputs){
|
|
| 252 | - if(!isset($this->inputs[$inputs])){
|
|
| 251 | + foreach ($expectedData = explode("|", $expected) as $inputs) {
|
|
| 252 | + if (!isset($this->inputs[$inputs])) {
|
|
| 253 | 253 | $expectedValues[] = $inputs; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // if the expectedData and expectedValues ββ |
| 258 | 258 | // array are numerically equal to the expected key, the exception is thrown. |
| 259 | - if(count($expectedData)===count($expectedValues)){
|
|
| 260 | - exception('clientExpected',['key'=>$expected])
|
|
| 261 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object');
|
|
| 259 | + if (count($expectedData)===count($expectedValues)) {
|
|
| 260 | + exception('clientExpected', ['key'=>$expected])
|
|
| 261 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object');
|
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -273,17 +273,17 @@ discard block |
||
| 273 | 273 | {
|
| 274 | 274 | // check the presence of the generator object |
| 275 | 275 | // and operate the generator over this object. |
| 276 | - if($this->checkProperties('auto_generators')){
|
|
| 276 | + if ($this->checkProperties('auto_generators')) {
|
|
| 277 | 277 | $generators = $this->getAutoGenerators(); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // check the presence of the generator object |
| 281 | 281 | // and operate the generator over this object. |
| 282 | - if($this->checkProperties('generators')){
|
|
| 283 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
| 282 | + if ($this->checkProperties('generators')) {
|
|
| 283 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if(isset($generators)){
|
|
| 286 | + if (isset($generators)) {
|
|
| 287 | 287 | $this->generatorMethod($generators); |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -298,21 +298,21 @@ discard block |
||
| 298 | 298 | private function generatorMethod($generators) |
| 299 | 299 | {
|
| 300 | 300 | //generator array object |
| 301 | - foreach ($generators as $generator){
|
|
| 301 | + foreach ($generators as $generator) {
|
|
| 302 | 302 | |
| 303 | 303 | //generator method name |
| 304 | 304 | $generatorMethodName = $generator.'Generator'; |
| 305 | 305 | |
| 306 | 306 | // if the generator method is present, |
| 307 | 307 | // the fake value is assigned. |
| 308 | - if(method_exists($this,$generatorMethodName)){
|
|
| 308 | + if (method_exists($this, $generatorMethodName)) {
|
|
| 309 | 309 | |
| 310 | 310 | //fake registration |
| 311 | - if(!isset($this->inputs[$generator])){
|
|
| 311 | + if (!isset($this->inputs[$generator])) {
|
|
| 312 | 312 | |
| 313 | 313 | $generatorMethodNameResult = $this->{$generatorMethodName}();
|
| 314 | 314 | |
| 315 | - if(!is_null($generatorMethodNameResult)){
|
|
| 315 | + if (!is_null($generatorMethodNameResult)) {
|
|
| 316 | 316 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 317 | 317 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 318 | 318 | $this->requestData[$generator] = $this->inputs[$generator]; |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | else {
|
| 323 | 323 | |
| 324 | - if($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 325 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
|
| 324 | + if ($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 325 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) {
|
|
| 326 | 326 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 327 | 327 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if($this->checkProperties('generators_dont_overwrite')
|
|
| 331 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){
|
|
| 330 | + if ($this->checkProperties('generators_dont_overwrite')
|
|
| 331 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) {
|
|
| 332 | 332 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 333 | 333 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 334 | 334 | } |
@@ -350,11 +350,11 @@ discard block |
||
| 350 | 350 | $list = []; |
| 351 | 351 | |
| 352 | 352 | foreach ($this->requestData as $key=>$item) {
|
| 353 | - if(property_exists($this,'requestExcept') && !in_array($key,$this->requestExcept)){
|
|
| 353 | + if (property_exists($this, 'requestExcept') && !in_array($key, $this->requestExcept)) {
|
|
| 354 | 354 | $list[$key] = $item; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if(!property_exists($this,'requestExcept')){
|
|
| 357 | + if (!property_exists($this, 'requestExcept')) {
|
|
| 358 | 358 | $list[$key] = $item; |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | {
|
| 398 | 398 | // we use the http method to write |
| 399 | 399 | // the values to the inputs and origin properties. |
| 400 | - foreach($this->clientData as $key=>$value){
|
|
| 400 | + foreach ($this->clientData as $key=>$value) {
|
|
| 401 | 401 | |
| 402 | 402 | //inputs and origin properties |
| 403 | 403 | $this->inputs[$key] = $value; |
@@ -444,9 +444,9 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | // we update the input values ββafter |
| 446 | 446 | // we receive and check the saved objects. |
| 447 | - foreach ($clientObjects as $key=>$value){
|
|
| 447 | + foreach ($clientObjects as $key=>$value) {
|
|
| 448 | 448 | |
| 449 | - if(isset($clientObjects['origin'][$key])){
|
|
| 449 | + if (isset($clientObjects['origin'][$key])) {
|
|
| 450 | 450 | |
| 451 | 451 | $this->{$key} = $clientObjects['origin'][$key];
|
| 452 | 452 | $this->inputs[$key] = $this->{$key};
|
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | // the request update to be performed using |
| 475 | 475 | // the method name to be used with the http method. |
| 476 | - $this->setRequestInputs($requestMethod,$key); |
|
| 476 | + $this->setRequestInputs($requestMethod, $key); |
|
| 477 | 477 | |
| 478 | 478 | // the request update to be performed using |
| 479 | 479 | // the method name to be used without the http method. |
| 480 | - $this->setRequestInputs($key,$key); |
|
| 480 | + $this->setRequestInputs($key, $key); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -488,20 +488,20 @@ discard block |
||
| 488 | 488 | * |
| 489 | 489 | * @throws ReflectionExceptionAlias |
| 490 | 490 | */ |
| 491 | - private function setRequestInputs($method,$key) |
|
| 491 | + private function setRequestInputs($method, $key) |
|
| 492 | 492 | {
|
| 493 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
|
|
| 493 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
|
|
| 494 | 494 | |
| 495 | 495 | //check annotations for method |
| 496 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
| 497 | - $annotation->annotation($method,$key); |
|
| 496 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
| 497 | + $annotation->annotation($method, $key); |
|
| 498 | 498 | |
| 499 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
|
|
| 499 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
|
|
| 500 | 500 | |
| 501 | 501 | $inputKeys = $this->inputs[$key]; |
| 502 | 502 | |
| 503 | 503 | $this->inputs[$key] = []; |
| 504 | - foreach ($inputKeys as $input){
|
|
| 504 | + foreach ($inputKeys as $input) {
|
|
| 505 | 505 | |
| 506 | 506 | $this->{$key} = $input;
|
| 507 | 507 | $keyMethod = $this->{$method}();
|
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | $this->requestData[$key][] = $keyMethod; |
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | - else{
|
|
| 513 | - if(isset($this->inputs[$key])){
|
|
| 512 | + else {
|
|
| 513 | + if (isset($this->inputs[$key])) {
|
|
| 514 | 514 | $keyMethod = $this->{$method}();
|
| 515 | 515 | $this->inputs[$key] = $keyMethod; |
| 516 | 516 | $this->requestData[$key] = $keyMethod; |
@@ -529,8 +529,8 @@ discard block |
||
| 529 | 529 | {
|
| 530 | 530 | // the auto object validate property is the property |
| 531 | 531 | // where all of your request values ββare automatically validated. |
| 532 | - if(property_exists($this,'autoObjectValidate') |
|
| 533 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
|
|
| 532 | + if (property_exists($this, 'autoObjectValidate') |
|
| 533 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
|
|
| 534 | 534 | $this->autoValidate('autoObjectValidate');
|
| 535 | 535 | } |
| 536 | 536 | } |
@@ -24,29 +24,29 @@ discard block |
||
| 24 | 24 | * @param $arg |
| 25 | 25 | * @return mixed |
| 26 | 26 | */ |
| 27 | - public static function annotationsLoaders($service,$arg) |
|
| 27 | + public static function annotationsLoaders($service, $arg) |
|
| 28 | 28 | {
|
| 29 | 29 | //factory runner |
| 30 | - if($service=="factory"){
|
|
| 30 | + if ($service=="factory") {
|
|
| 31 | 31 | return self::factory(); |
| 32 | 32 | } |
| 33 | 33 | //if $name starts with $needles for repository |
| 34 | - if(Str::endsWith($service,'Repository')){
|
|
| 34 | + if (Str::endsWith($service, 'Repository')) {
|
|
| 35 | 35 | return self::repository($service); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | //if $name starts with $needles for source |
| 39 | - if(Str::endsWith($service,'Source')){
|
|
| 40 | - return self::source($service,$arg); |
|
| 39 | + if (Str::endsWith($service, 'Source')) {
|
|
| 40 | + return self::source($service, $arg); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | //if $name starts with $needles for model |
| 44 | - if(Str::endsWith($service,'Builder')){
|
|
| 44 | + if (Str::endsWith($service, 'Builder')) {
|
|
| 45 | 45 | return self::Builder(ucfirst($service)); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - if(method_exists(new self,$service)){
|
|
| 49 | + if (method_exists(new self, $service)) {
|
|
| 50 | 50 | return self::$service($arg); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | private static function builder($service) |
| 100 | 100 | {
|
| 101 | 101 | //we are making a namespace assignment for the builder. |
| 102 | - $builder=app()->namespace()->builder().'\BuilderMap'; |
|
| 102 | + $builder = app()->namespace()->builder().'\BuilderMap'; |
|
| 103 | 103 | |
| 104 | 104 | //we are getting builder instance. |
| 105 | 105 | return app()->resolve($builder); |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | * @param array $bind |
| 128 | 128 | * @return mixed |
| 129 | 129 | */ |
| 130 | - public function container($instance,$class,$bind=array()) |
|
| 130 | + public function container($instance, $class, $bind = array()) |
|
| 131 | 131 | {
|
| 132 | - if(!property_exists($instance->container(),$class)){
|
|
| 132 | + if (!property_exists($instance->container(), $class)) {
|
|
| 133 | 133 | throw new \InvalidArgumentException('container object false for ('.$class.') object');
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $container=$instance->container()->{$class};
|
|
| 136 | + $container = $instance->container()->{$class};
|
|
| 137 | 137 | |
| 138 | - if(!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)){
|
|
| 139 | - return $instance->resolve($container,$bind); |
|
| 138 | + if (!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)) {
|
|
| 139 | + return $instance->resolve($container, $bind); |
|
| 140 | 140 | } |
| 141 | 141 | return $instance->container()->{$class};
|
| 142 | 142 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function createAppInstance($object) |
| 148 | 148 | {
|
| 149 | - if(!defined('appInstance')){
|
|
| 150 | - define('appInstance',(base64_encode(serialize($object))));
|
|
| 149 | + if (!defined('appInstance')) {
|
|
| 150 | + define('appInstance', (base64_encode(serialize($object))));
|
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | * @param array $arg |
| 156 | 156 | * @return mixed |
| 157 | 157 | */ |
| 158 | - private static function date($arg=array()) |
|
| 158 | + private static function date($arg = array()) |
|
| 159 | 159 | {
|
| 160 | - $locale = (count($arg)=="0") ? config('app.locale','en') : current($arg);
|
|
| 160 | + $locale = (count($arg)=="0") ? config('app.locale', 'en') : current($arg);
|
|
| 161 | 161 | |
| 162 | 162 | return app()->resolve(Date::class)->setLocale($locale); |
| 163 | 163 | } |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | {
|
| 178 | 178 | //we save an instance for the entire application |
| 179 | 179 | //and add it to the helper file to be accessed from anywhere in the application. |
| 180 | - if(!isset(self::$instance['appInstance'])){
|
|
| 181 | - self::$instance['appInstance']=unserialize(base64_decode(appInstance)); |
|
| 180 | + if (!isset(self::$instance['appInstance'])) {
|
|
| 181 | + self::$instance['appInstance'] = unserialize(base64_decode(appInstance)); |
|
| 182 | 182 | return self::$instance['appInstance']; |
| 183 | 183 | } |
| 184 | 184 | return self::$instance['appInstance']; |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | private static function queue() |
| 207 | 207 | {
|
| 208 | - if(!isset(self::$instance['queue'])){
|
|
| 208 | + if (!isset(self::$instance['queue'])) {
|
|
| 209 | 209 | |
| 210 | - self::$instance['queue']=(new Queue()); |
|
| 210 | + self::$instance['queue'] = (new Queue()); |
|
| 211 | 211 | return self::$instance['queue']; |
| 212 | 212 | |
| 213 | 213 | } |
@@ -219,18 +219,18 @@ discard block |
||
| 219 | 219 | * @param bool $namespace |
| 220 | 220 | * @return string |
| 221 | 221 | */ |
| 222 | - public static function repository($service,$namespace=false) |
|
| 222 | + public static function repository($service, $namespace = false) |
|
| 223 | 223 | {
|
| 224 | 224 | //I can get the repository name from the magic method as a salt repository, |
| 225 | 225 | //after which we will edit it as an adapter namespace. |
| 226 | - $repositoryName=ucfirst(preg_replace('@Repository@is','',$service));
|
|
| 226 | + $repositoryName = ucfirst(preg_replace('@Repository@is', '', $service));
|
|
| 227 | 227 | |
| 228 | 228 | //If we then configure the name of the simple repository to be an adapter |
| 229 | 229 | //then we will give the user an example of the adapter class in each repository call. |
| 230 | 230 | $repositoryAdapterName = $repositoryName.'Adapter'; |
| 231 | 231 | $repositoryNamespace = app()->namespace()->repository().'\\'.$repositoryName.'\\'.$repositoryAdapterName; |
| 232 | 232 | |
| 233 | - if($namespace) return $repositoryNamespace; |
|
| 233 | + if ($namespace) return $repositoryNamespace; |
|
| 234 | 234 | |
| 235 | 235 | //and eventually we conclude the adapter class of the repository package as an instance. |
| 236 | 236 | return app()->resolve($repositoryNamespace)->adapter(); |
@@ -241,17 +241,17 @@ discard block |
||
| 241 | 241 | * @param $arg |
| 242 | 242 | * @return mixed |
| 243 | 243 | */ |
| 244 | - private static function source($service,$arg) |
|
| 244 | + private static function source($service, $arg) |
|
| 245 | 245 | {
|
| 246 | 246 | //get Source path |
| 247 | - $service=ucfirst($service); |
|
| 248 | - $getCalledClass=str_replace('\\'.class_basename($arg[0]),'',get_class($arg[0]));
|
|
| 249 | - $getCalledClass=class_basename($getCalledClass); |
|
| 247 | + $service = ucfirst($service); |
|
| 248 | + $getCalledClass = str_replace('\\'.class_basename($arg[0]), '', get_class($arg[0]));
|
|
| 249 | + $getCalledClass = class_basename($getCalledClass); |
|
| 250 | 250 | |
| 251 | - $service=str_replace($getCalledClass,'',$service); |
|
| 251 | + $service = str_replace($getCalledClass, '', $service); |
|
| 252 | 252 | |
| 253 | 253 | //run service for endpoint |
| 254 | - $serviceSource=StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main'; |
|
| 254 | + $serviceSource = StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main'; |
|
| 255 | 255 | return app()->resolve($serviceSource); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public static function redis() |
| 262 | 262 | {
|
| 263 | - if(!isset(self::$instance['redis'])){
|
|
| 263 | + if (!isset(self::$instance['redis'])) {
|
|
| 264 | 264 | |
| 265 | - self::$instance['redis']=(new Redis())->client(); |
|
| 265 | + self::$instance['redis'] = (new Redis())->client(); |
|
| 266 | 266 | return self::$instance['redis']; |
| 267 | 267 | |
| 268 | 268 | } |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | * @param null $param |
| 274 | 274 | * @return array|null|string |
| 275 | 275 | */ |
| 276 | - public function route($param=null) |
|
| 276 | + public function route($param = null) |
|
| 277 | 277 | {
|
| 278 | - $kernel=self::getAppInstance()->kernel; |
|
| 278 | + $kernel = self::getAppInstance()->kernel; |
|
| 279 | 279 | |
| 280 | - $saltRouteParameters=$kernel->routeParameters; |
|
| 280 | + $saltRouteParameters = $kernel->routeParameters; |
|
| 281 | 281 | |
| 282 | - if($param===null){
|
|
| 282 | + if ($param===null) {
|
|
| 283 | 283 | return $saltRouteParameters; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -295,25 +295,25 @@ discard block |
||
| 295 | 295 | * @param array $select |
| 296 | 296 | * @return mixed|string |
| 297 | 297 | */ |
| 298 | - public function translator($data,$select=array()) |
|
| 298 | + public function translator($data, $select = array()) |
|
| 299 | 299 | {
|
| 300 | 300 | $languageDir = path()->appLanguage(); |
| 301 | 301 | |
| 302 | - $lang=(new Lingua($languageDir)); |
|
| 302 | + $lang = (new Lingua($languageDir)); |
|
| 303 | 303 | |
| 304 | - if(self::app()->has('locale')){
|
|
| 304 | + if (self::app()->has('locale')) {
|
|
| 305 | 305 | $defaultLocale = self::app()->get('locale');
|
| 306 | 306 | } |
| 307 | - else{
|
|
| 307 | + else {
|
|
| 308 | 308 | $defaultLocale = config('app.locale');
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if(!file_exists($languageDir.''.DIRECTORY_SEPARATOR.''.$defaultLocale)){
|
|
| 311 | + if (!file_exists($languageDir.''.DIRECTORY_SEPARATOR.''.$defaultLocale)) {
|
|
| 312 | 312 | $defaultLocale = config('app.fallback_locale');
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - if(count($select)){
|
|
| 316 | - return $lang->include(['default'])->locale($defaultLocale)->get($data,$select); |
|
| 315 | + if (count($select)) {
|
|
| 316 | + return $lang->include(['default'])->locale($defaultLocale)->get($data, $select); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | return $lang->include(['default'])->locale($defaultLocale)->get($data); |