Test Setup Failed
Push — master ( d6e715...def4fd )
by Php Easy Api
03:30 queued 45s
created
src/resta/Container/Container.php 2 patches
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Resta\Console\ConsoleBindings;
8 8
 use Resta\Contracts\ContainerContracts;
9 9
 
10
-class Container implements ContainerContracts,\ArrayAccess
10
+class Container implements ContainerContracts, \ArrayAccess
11 11
 {
12 12
     /**
13 13
      * @var bool
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      * @param array $bind
50 50
      * @return array
51 51
      */
52
-    public function applicationProviderBinding($make,$bind=array())
52
+    public function applicationProviderBinding($make, $bind = array())
53 53
     {
54 54
         //service container is an automatic application provider
55 55
         //that we can bind to the special class di in the dependency condition.
56 56
         //This method is automatically added to the classes resolved by the entire make bind method.
57
-        return array_merge($bind,['app'=>$make]);
57
+        return array_merge($bind, ['app'=>$make]);
58 58
     }
59 59
 
60 60
     /**
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
      * @throws DependencyException
66 66
      * @throws NotFoundException
67 67
      */
68
-    public function bind($object=null,$callback=null)
68
+    public function bind($object = null, $callback = null)
69 69
     {
70 70
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
71 71
         //Otherwise, when the bind object and callback are sent, the closure class inherits
72 72
         //the applicationProvider object and the resolve method is called
73
-        return $this->make($object,$callback,'container');
73
+        return $this->make($object, $callback, 'container');
74 74
     }
75 75
 
76 76
     /**
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
      * @throws DependencyException
83 83
      * @throws NotFoundException
84 84
      */
85
-    private function build($object,$callback,$sync=false)
85
+    private function build($object, $callback, $sync = false)
86 86
     {
87 87
         //If the console object returns true,
88 88
         //we do not cancel binding operations
89 89
         //We are getting what applies to console with consoleKernelObject.
90
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback);
90
+        if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback);
91 91
 
92 92
         //the value corresponding to the bind value for the global object is assigned and
93 93
         //the resolve method is called for the dependency injection.
94
-        $this->kernelAssigner()->setKernelObject($object,$callback);
94
+        $this->kernelAssigner()->setKernelObject($object, $callback);
95 95
 
96 96
         //return kernel object
97 97
         return $this->kernel();
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
      * @throws DependencyException
107 107
      * @throws NotFoundException
108 108
      */
109
-    private function consoleKernelObject($object,$callback,$container=false)
109
+    private function consoleKernelObject($object, $callback, $container = false)
110 110
     {
111 111
         //we use the console bindings class to specify the classes to be preloaded in the console application.
112 112
         //Thus, classes that can not be bound with http are called without closure in global loaders directory.
113
-        $this->resolve(ConsoleBindings::class)->console($object,$callback,$container);
113
+        $this->resolve(ConsoleBindings::class)->console($object, $callback, $container);
114 114
 
115 115
         //The console application must always return the kernel method.
116 116
         return $this->kernel();
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @throws DependencyException
126 126
      * @throws NotFoundException
127 127
      */
128
-    private function consoleKernelObjectChecker($object,$callback,$container=false)
128
+    private function consoleKernelObjectChecker($object, $callback, $container = false)
129 129
     {
130 130
         //we check whether the callback value is a callable function.
131 131
         $isCallableForCallback = is_callable($callback);
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
         //If the console object returns true,
134 134
         //we do not cancel binding operations
135 135
         //We are getting what applies to console with consoleKernelObject.
136
-        if($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object,$callback,$container);
136
+        if ($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object, $callback, $container);
137 137
 
138 138
         //If the application is not a console operation, we re-bind to existing methods synchronously.
139
-        return ($container) ? $this->containerBuild($object,$callback,true) : $this->build($object,$callback,true);
139
+        return ($container) ? $this->containerBuild($object, $callback, true) : $this->build($object, $callback, true);
140 140
     }
141 141
 
142 142
     /**
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
      * @throws DependencyException
147 147
      * @throws NotFoundException
148 148
      */
149
-    private function consoleShared($object,$callback)
149
+    private function consoleShared($object, $callback)
150 150
     {
151 151
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
152 152
         //The work to be done here is to bind the classes to be included in the console share privately.
153
-        $this->kernelAssigner()->consoleShared($object,$callback);
153
+        $this->kernelAssigner()->consoleShared($object, $callback);
154 154
     }
155 155
 
156 156
     /**
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
      * @throws DependencyException
163 163
      * @throws NotFoundException
164 164
      */
165
-    public function containerBuild($object,$callback,$sync=false)
165
+    public function containerBuild($object, $callback, $sync = false)
166 166
     {
167 167
         //If the console object returns true,
168 168
         //we do not cancel binding operations
169 169
         //We are getting what applies to console with consoleKernelObject.
170
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback,true);
170
+        if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback, true);
171 171
 
172 172
         //Since the objects that come to the build method are objects from the container method,
173 173
         //we need to automatically create a kernel object named serviceContainer in this method.
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
         //the value corresponding to the bind value for the global object is assigned and
177 177
         //the resolve method is called for the dependency method.
178
-        $this->kernelAssigner()->setKernelObject($object,$callback,'serviceContainer');
178
+        $this->kernelAssigner()->setKernelObject($object, $callback, 'serviceContainer');
179 179
 
180 180
         //return kernel object
181 181
         return $this->kernel();
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
      * @param $class
186 186
      * @param $bind
187 187
      */
188
-    private function contextualBindCleaner($class,$bind)
188
+    private function contextualBindCleaner($class, $bind)
189 189
     {
190 190
         //the context bind objects are checked again and the bind sequence submitted by
191 191
         //the user is checked and forced to re-instantiate the object.
192
-        if(isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind){
192
+        if (isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind) {
193 193
             unset(self::$instance[$class]);
194 194
             unset(self::$bindParams[$class]);
195 195
         }
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 
209 209
         // the has method can have a dotted string value so
210 210
         // we need to be able to control the string or array within the container.
211
-        foreach (explode(".",$abstract) as $item){
212
-            if(isset($container[$item])){
211
+        foreach (explode(".", $abstract) as $item) {
212
+            if (isset($container[$item])) {
213 213
                 $container = $container[$item];
214 214
             }
215
-            else{
216
-                if(!is_null($container[$item])){
215
+            else {
216
+                if (!is_null($container[$item])) {
217 217
                     $container = $container[$item];
218 218
                 }
219 219
             }
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 
238 238
         // the has method can have a dotted string value so
239 239
         // we need to be able to control the string or array within the container.
240
-        foreach (explode(".",$abstract) as $item){
240
+        foreach (explode(".", $abstract) as $item) {
241 241
 
242 242
             // this blog will work
243 243
             // if the data in the container loop points to an array.
244
-            if(!is_array($container)){
244
+            if (!is_array($container)) {
245 245
 
246 246
                 // we are querying the value of
247 247
                 // the items corresponding to the dotted value in the container.
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                 $container = $container[$item];
250 250
                 $bools[] = is_null($container) ? false : true;
251 251
             }
252
-            else{
252
+            else {
253 253
 
254 254
                 // if the container array corresponds to a string,
255 255
                 // the bools array is filled with the isset control directly.
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
         // the method returns false if the bools sequence is false,
261 261
         // otherwise it will return true.
262
-        return in_array(false,$bools) ? false : true;
262
+        return in_array(false, $bools) ? false : true;
263 263
     }
264 264
 
265 265
     /**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * @throws DependencyException
310 310
      * @throws NotFoundException
311 311
      */
312
-    public function make($object=null,$callback=null,$container=false)
312
+    public function make($object = null, $callback = null, $container = false)
313 313
     {
314 314
         //we check whether the boolean value of the singleton variable used
315 315
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 
318 318
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
319 319
         //The work to be done here is to bind the classes to be included in the console share privately.
320
-        if($container){
321
-            $this->consoleShared($object,$callback);
320
+        if ($container) {
321
+            $this->consoleShared($object, $callback);
322 322
         }
323 323
 
324 324
         //If the third parameter passed to the bind method carries a container value,
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
329 329
         //Otherwise, when the bind object and callback are sent, the closure class inherits
330 330
         //the applicationProvider object and the resolve method is called
331
-        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object,$callback);
331
+        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object, $callback);
332 332
     }
333 333
 
334 334
     /**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      */
349 349
     public function offsetGet($offset) {
350 350
 
351
-        return $this->resolve($this->instances['containerInstanceResolve'],[
351
+        return $this->resolve($this->instances['containerInstanceResolve'], [
352 352
             'instances' => $this->instances
353 353
         ])->{$offset}();
354 354
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      * @param null $concrete
373 373
      * @return bool|mixed
374 374
      */
375
-    public function register($key,$object,$concrete=null)
375
+    public function register($key, $object, $concrete = null)
376 376
     {
377 377
         // we assign the values ​​required
378 378
         // for register to the global value variable.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
         // If there is an instance of the application class,
384 384
         // the register method is saved both in this example and in the global.
385
-        if(defined('appInstance')){
385
+        if (defined('appInstance')) {
386 386
 
387 387
             // where we will assign both the global instance
388 388
             // and the registered application object.
@@ -401,19 +401,19 @@  discard block
 block discarded – undo
401 401
      * @param bool $withConcrete
402 402
      * @return bool
403 403
      */
404
-    private function registerProcess($instance,$withConcrete=false)
404
+    private function registerProcess($instance, $withConcrete = false)
405 405
     {
406 406
         // values recorded without concrete.
407 407
         // or values deleted
408
-        if(false===$withConcrete){
408
+        if (false===$withConcrete) {
409 409
 
410 410
             //values registered without concrete
411
-            $instance->{$this->values['key']}=$this->values['object'];
411
+            $instance->{$this->values['key']} = $this->values['object'];
412 412
             return false;
413 413
         }
414 414
 
415 415
         //values registered with concrete
416
-        $instance->{$this->values['key']}[$this->values['object']]=$this->values['concrete'];
416
+        $instance->{$this->values['key']}[$this->values['object']] = $this->values['concrete'];
417 417
     }
418 418
 
419 419
     /**
@@ -424,22 +424,22 @@  discard block
 block discarded – undo
424 424
      * @throws DependencyException
425 425
      * @throws NotFoundException
426 426
      */
427
-    public function resolve($class,$bind=array())
427
+    public function resolve($class, $bind = array())
428 428
     {
429 429
         //the context bind objects are checked again and the bind sequence submitted by
430 430
         //the user is checked and forced to re-instantiate the object.
431
-        $this->contextualBindCleaner($class,$bind);
431
+        $this->contextualBindCleaner($class, $bind);
432 432
 
433 433
         //We do an instance check to get the static instance values of
434 434
         //the classes to be resolved with the make bind method.
435
-        if(!isset(self::$instance[$class])){
435
+        if (!isset(self::$instance[$class])) {
436 436
 
437 437
             //bind params object
438 438
             self::$bindParams[$class] = $bind;
439 439
 
440 440
             //By singleton checking, we solve the dependency injection of the given class.
441 441
             //Thus, each class can be called together with its dependency.
442
-            self::$instance[$class] = DIContainerManager::make($class,$this->applicationProviderBinding($this,self::$bindParams[$class]));
442
+            self::$instance[$class] = DIContainerManager::make($class, $this->applicationProviderBinding($this, self::$bindParams[$class]));
443 443
             $this->singleton()->resolved[$class] = self::$instance[$class];
444 444
 
445 445
             //return resolve class
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
      * @param $class
458 458
      * @return mixed
459 459
      */
460
-    public function resolved($class){
460
+    public function resolved($class) {
461 461
 
462
-        if(isset($this['resolved'][$class])){
462
+        if (isset($this['resolved'][$class])) {
463 463
             return $this['resolved'][$class];
464 464
         }
465 465
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
      * @throws DependencyException
475 475
      * @throws NotFoundException
476 476
      */
477
-    public function share($object=null,$callback=null)
477
+    public function share($object = null, $callback = null)
478 478
     {
479 479
         //we check whether the boolean value of the singleton variable used
480 480
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
 
483 483
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
484 484
         //The work to be done here is to bind the classes to be included in the console share privately.
485
-        $this->consoleShared($object,$callback);
485
+        $this->consoleShared($object, $callback);
486 486
 
487 487
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
488 488
         //Otherwise, when the bind object and callback are sent, the closure class inherits
489 489
         //the applicationProvider object and the resolve method is called
490
-        return ($object===null) ? $this->kernel() : $this->build($object,$callback);
490
+        return ($object===null) ? $this->kernel() : $this->build($object, $callback);
491 491
 
492 492
     }
493 493
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
      */
508 508
     public function singleton()
509 509
     {
510
-        if($this->singleton===false){
510
+        if ($this->singleton===false) {
511 511
 
512 512
             //after first initializing, the singleton variable is set to true,
513 513
             //and subsequent incoming classes can inherit the loaded object.
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
         // for application instance
529 529
         // if the values ​​to be saved are to be saved without the concrete,
530 530
         // if it is an array.
531
-        if($this->values['concrete']===null) {
531
+        if ($this->values['concrete']===null) {
532 532
 
533 533
             // Without concrete,
534 534
             // the saved value will be saved
535 535
             // if the it does not exist in application instance.
536
-            if(!isset($instance->{$this->values['key']})) {
536
+            if (!isset($instance->{$this->values['key']})) {
537 537
                 $this->registerProcess($instance);
538 538
             }
539 539
             return false;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
         // We send concrete values to be recorded with concrete as true.
543 543
         // these values will be recorded as a array.
544
-        $this->registerProcess($instance,true);
544
+        $this->registerProcess($instance, true);
545 545
     }
546 546
 
547 547
     /**
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
      * @param null|string $object
550 550
      * @return mixed
551 551
      */
552
-    public function terminate($key,$object=null)
552
+    public function terminate($key, $object = null)
553 553
     {
554 554
         // object null is
555 555
         // sent to just terminate a key.
556
-        if($object===null){
556
+        if ($object===null) {
557 557
             unset(core()->{$key});
558 558
             unset($this->singleton()->{$key});
559 559
             return false;
Please login to merge, or discard this patch.
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,7 +87,9 @@  discard block
 block discarded – undo
87 87
         //If the console object returns true,
88 88
         //we do not cancel binding operations
89 89
         //We are getting what applies to console with consoleKernelObject.
90
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback);
90
+        if($sync===false) {
91
+            return $this->consoleKernelObjectChecker($object,$callback);
92
+        }
91 93
 
92 94
         //the value corresponding to the bind value for the global object is assigned and
93 95
         //the resolve method is called for the dependency injection.
@@ -133,7 +135,9 @@  discard block
 block discarded – undo
133 135
         //If the console object returns true,
134 136
         //we do not cancel binding operations
135 137
         //We are getting what applies to console with consoleKernelObject.
136
-        if($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object,$callback,$container);
138
+        if($this->console() AND $isCallableForCallback) {
139
+            return $this->consoleKernelObject($object,$callback,$container);
140
+        }
137 141
 
138 142
         //If the application is not a console operation, we re-bind to existing methods synchronously.
139 143
         return ($container) ? $this->containerBuild($object,$callback,true) : $this->build($object,$callback,true);
@@ -167,7 +171,9 @@  discard block
 block discarded – undo
167 171
         //If the console object returns true,
168 172
         //we do not cancel binding operations
169 173
         //We are getting what applies to console with consoleKernelObject.
170
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback,true);
174
+        if($sync===false) {
175
+            return $this->consoleKernelObjectChecker($object,$callback,true);
176
+        }
171 177
 
172 178
         //Since the objects that come to the build method are objects from the container method,
173 179
         //we need to automatically create a kernel object named serviceContainer in this method.
@@ -211,8 +217,7 @@  discard block
 block discarded – undo
211 217
         foreach (explode(".",$abstract) as $item){
212 218
             if(isset($container[$item])){
213 219
                 $container = $container[$item];
214
-            }
215
-            else{
220
+            } else{
216 221
                 if(!is_null($container[$item])){
217 222
                     $container = $container[$item];
218 223
                 }
@@ -248,8 +253,7 @@  discard block
 block discarded – undo
248 253
                 // the control result is transferred to the bools array.
249 254
                 $container = $container[$item];
250 255
                 $bools[] = is_null($container) ? false : true;
251
-            }
252
-            else{
256
+            } else{
253 257
 
254 258
                 // if the container array corresponds to a string,
255 259
                 // the bools array is filled with the isset control directly.
Please login to merge, or discard this patch.