Test Setup Failed
Push β€” master ( 4c7ace...8edce4 )
by Php Easy Api
20:25 queued 16:59
created
src/resta/Container/Container.php 1 patch
Spacing   +55 added lines, -55 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,16 +49,16 @@  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
-        if(defined('appInstance')){
54
+        if (defined('appInstance')) {
55 55
             //
56 56
         }
57 57
 
58 58
         //service container is an automatic application provider
59 59
         //that we can bind to the special class di in the dependency condition.
60 60
         //This method is automatically added to the classes resolved by the entire make bind method.
61
-        return array_merge($bind,['app'=>$make]);
61
+        return array_merge($bind, ['app'=>$make]);
62 62
     }
63 63
 
64 64
     /**
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
      * @throws DependencyException
71 71
      * @throws NotFoundException
72 72
      */
73
-    public function bind($object=null,$callback=null,$alias=null)
73
+    public function bind($object = null, $callback = null, $alias = null)
74 74
     {
75
-        if(!is_null($alias)){
75
+        if (!is_null($alias)) {
76 76
             $object = $alias;
77 77
         }
78 78
 
79 79
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
80 80
         //Otherwise, when the bind object and callback are sent, the closure class inherits
81 81
         //the applicationProvider object and the resolve method is called
82
-        return $this->make($object,$callback,'container');
82
+        return $this->make($object, $callback, 'container');
83 83
     }
84 84
 
85 85
     /**
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
      * @throws DependencyException
92 92
      * @throws NotFoundException
93 93
      */
94
-    private function build($object,$callback,$sync=false)
94
+    private function build($object, $callback, $sync = false)
95 95
     {
96 96
         //If the console object returns true,
97 97
         //we do not cancel binding operations
98 98
         //We are getting what applies to console with consoleKernelObject.
99
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback);
99
+        if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback);
100 100
 
101 101
         //the value corresponding to the bind value for the global object is assigned and
102 102
         //the resolve method is called for the dependency injection.
103
-        $this->kernelAssigner()->setKernelObject($object,$callback);
103
+        $this->kernelAssigner()->setKernelObject($object, $callback);
104 104
 
105 105
         //return kernel object
106 106
         return $this->kernel();
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
      * @throws DependencyException
116 116
      * @throws NotFoundException
117 117
      */
118
-    private function consoleKernelObject($object,$callback,$container=false)
118
+    private function consoleKernelObject($object, $callback, $container = false)
119 119
     {
120 120
         //we use the console bindings class to specify the classes to be preloaded in the console application.
121 121
         //Thus, classes that can not be bound with http are called without closure in global loaders directory.
122
-        $this->resolve(ConsoleBindings::class)->console($object,$callback,$container);
122
+        $this->resolve(ConsoleBindings::class)->console($object, $callback, $container);
123 123
 
124 124
         //The console application must always return the kernel method.
125 125
         return $this->kernel();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @throws DependencyException
135 135
      * @throws NotFoundException
136 136
      */
137
-    private function consoleKernelObjectChecker($object,$callback,$container=false)
137
+    private function consoleKernelObjectChecker($object, $callback, $container = false)
138 138
     {
139 139
         //we check whether the callback value is a callable function.
140 140
         $isCallableForCallback = is_callable($callback);
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
         //If the console object returns true,
143 143
         //we do not cancel binding operations
144 144
         //We are getting what applies to console with consoleKernelObject.
145
-        if($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object,$callback,$container);
145
+        if ($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object, $callback, $container);
146 146
 
147 147
         //If the application is not a console operation, we re-bind to existing methods synchronously.
148
-        return ($container) ? $this->containerBuild($object,$callback,true) : $this->build($object,$callback,true);
148
+        return ($container) ? $this->containerBuild($object, $callback, true) : $this->build($object, $callback, true);
149 149
     }
150 150
 
151 151
     /**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
      * @throws DependencyException
156 156
      * @throws NotFoundException
157 157
      */
158
-    private function consoleShared($object,$callback)
158
+    private function consoleShared($object, $callback)
159 159
     {
160 160
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
161 161
         //The work to be done here is to bind the classes to be included in the console share privately.
162
-        $this->kernelAssigner()->consoleShared($object,$callback);
162
+        $this->kernelAssigner()->consoleShared($object, $callback);
163 163
     }
164 164
 
165 165
     /**
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
      * @throws DependencyException
172 172
      * @throws NotFoundException
173 173
      */
174
-    public function containerBuild($object,$callback,$sync=false)
174
+    public function containerBuild($object, $callback, $sync = false)
175 175
     {
176 176
         //If the console object returns true,
177 177
         //we do not cancel binding operations
178 178
         //We are getting what applies to console with consoleKernelObject.
179
-        if($sync===false) return $this->consoleKernelObjectChecker($object,$callback,true);
179
+        if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback, true);
180 180
 
181 181
         //Since the objects that come to the build method are objects from the container method,
182 182
         //we need to automatically create a kernel object named serviceContainer in this method.
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
         //the value corresponding to the bind value for the global object is assigned and
186 186
         //the resolve method is called for the dependency method.
187
-        $this->kernelAssigner()->setKernelObject($object,$callback,'serviceContainer');
187
+        $this->kernelAssigner()->setKernelObject($object, $callback, 'serviceContainer');
188 188
 
189 189
         //return kernel object
190 190
         return $this->kernel();
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
      * @param $class
195 195
      * @param $bind
196 196
      */
197
-    private function contextualBindCleaner($class,$bind)
197
+    private function contextualBindCleaner($class, $bind)
198 198
     {
199 199
         //the context bind objects are checked again and the bind sequence submitted by
200 200
         //the user is checked and forced to re-instantiate the object.
201
-        if(isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind){
201
+        if (isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind) {
202 202
             unset(self::$instance[$class]);
203 203
             unset(self::$bindParams[$class]);
204 204
         }
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 
218 218
         // the has method can have a dotted string value so
219 219
         // we need to be able to control the string or array within the container.
220
-        foreach (explode(".",$abstract) as $item){
221
-            if(isset($container[$item])){
220
+        foreach (explode(".", $abstract) as $item) {
221
+            if (isset($container[$item])) {
222 222
                 $container = $container[$item];
223 223
             }
224
-            else{
224
+            else {
225 225
                 return null;
226 226
             }
227 227
         }
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 
245 245
         // the has method can have a dotted string value so
246 246
         // we need to be able to control the string or array within the container.
247
-        foreach (explode(".",$abstract) as $item){
247
+        foreach (explode(".", $abstract) as $item) {
248 248
 
249 249
             // this blog will work
250 250
             // if the data in the container loop points to an array.
251
-            if(!is_array($container)){
251
+            if (!is_array($container)) {
252 252
 
253 253
                 // we are querying the value of
254 254
                 // the items corresponding to the dotted value in the container.
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 $container = $container[$item];
257 257
                 $bools[] = is_null($container) ? false : true;
258 258
             }
259
-            else{
259
+            else {
260 260
 
261 261
                 // if the container array corresponds to a string,
262 262
                 // the bools array is filled with the isset control directly.
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
         // the method returns false if the bools sequence is false,
268 268
         // otherwise it will return true.
269
-        return in_array(false,$bools) ? false : true;
269
+        return in_array(false, $bools) ? false : true;
270 270
     }
271 271
 
272 272
     /**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @throws DependencyException
317 317
      * @throws NotFoundException
318 318
      */
319
-    public function make($object=null,$callback=null,$container=false)
319
+    public function make($object = null, $callback = null, $container = false)
320 320
     {
321 321
         //we check whether the boolean value of the singleton variable used
322 322
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 
325 325
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
326 326
         //The work to be done here is to bind the classes to be included in the console share privately.
327
-        if($container){
328
-            $this->consoleShared($object,$callback);
327
+        if ($container) {
328
+            $this->consoleShared($object, $callback);
329 329
         }
330 330
 
331 331
         //If the third parameter passed to the bind method carries a container value,
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
336 336
         //Otherwise, when the bind object and callback are sent, the closure class inherits
337 337
         //the applicationProvider object and the resolve method is called
338
-        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object,$callback);
338
+        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object, $callback);
339 339
     }
340 340
 
341 341
     /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public function offsetGet($offset) {
357 357
 
358
-        return $this->resolve($this->instances['containerInstanceResolve'],[
358
+        return $this->resolve($this->instances['containerInstanceResolve'], [
359 359
             'instances' => $this->instances
360 360
         ])->{$offset}();
361 361
     }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      * @param null $concrete
380 380
      * @return bool|mixed
381 381
      */
382
-    public function register($key,$object,$concrete=null)
382
+    public function register($key, $object, $concrete = null)
383 383
     {
384 384
         // we assign the values ​​required
385 385
         // for register to the global value variable.
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
         // If there is an instance of the application class,
391 391
         // the register method is saved both in this example and in the global.
392
-        if(defined('appInstance')){
392
+        if (defined('appInstance')) {
393 393
 
394 394
             // where we will assign both the global instance
395 395
             // and the registered application object.
@@ -408,19 +408,19 @@  discard block
 block discarded – undo
408 408
      * @param bool $withConcrete
409 409
      * @return bool
410 410
      */
411
-    private function registerProcess($instance,$withConcrete=false)
411
+    private function registerProcess($instance, $withConcrete = false)
412 412
     {
413 413
         // values recorded without concrete.
414 414
         // or values deleted
415
-        if(false===$withConcrete){
415
+        if (false===$withConcrete) {
416 416
 
417 417
             //values registered without concrete
418
-            $instance->{$this->values['key']}=$this->values['object'];
418
+            $instance->{$this->values['key']} = $this->values['object'];
419 419
             return false;
420 420
         }
421 421
 
422 422
         //values registered with concrete
423
-        $instance->{$this->values['key']}[$this->values['object']]=$this->values['concrete'];
423
+        $instance->{$this->values['key']}[$this->values['object']] = $this->values['concrete'];
424 424
     }
425 425
 
426 426
     /**
@@ -431,22 +431,22 @@  discard block
 block discarded – undo
431 431
      * @throws DependencyException
432 432
      * @throws NotFoundException
433 433
      */
434
-    public function resolve($class,$bind=array())
434
+    public function resolve($class, $bind = array())
435 435
     {
436 436
         //the context bind objects are checked again and the bind sequence submitted by
437 437
         //the user is checked and forced to re-instantiate the object.
438
-        $this->contextualBindCleaner($class,$bind);
438
+        $this->contextualBindCleaner($class, $bind);
439 439
 
440 440
         //We do an instance check to get the static instance values of
441 441
         //the classes to be resolved with the make bind method.
442
-        if(!isset(self::$instance[$class])){
442
+        if (!isset(self::$instance[$class])) {
443 443
 
444 444
             //bind params object
445 445
             self::$bindParams[$class] = $bind;
446 446
 
447 447
             //By singleton checking, we solve the dependency injection of the given class.
448 448
             //Thus, each class can be called together with its dependency.
449
-            self::$instance[$class] = DIContainerManager::make($class,$this->applicationProviderBinding($this,self::$bindParams[$class]));
449
+            self::$instance[$class] = DIContainerManager::make($class, $this->applicationProviderBinding($this, self::$bindParams[$class]));
450 450
             $this->singleton()->resolved[$class] = self::$instance[$class];
451 451
 
452 452
             //return resolve class
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
      * @param $class
465 465
      * @return mixed
466 466
      */
467
-    public function resolved($class){
467
+    public function resolved($class) {
468 468
 
469
-        if(isset($this['resolved'][$class])){
469
+        if (isset($this['resolved'][$class])) {
470 470
             return $this['resolved'][$class];
471 471
         }
472 472
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
      * @throws DependencyException
482 482
      * @throws NotFoundException
483 483
      */
484
-    public function share($object=null,$callback=null)
484
+    public function share($object = null, $callback = null)
485 485
     {
486 486
         //we check whether the boolean value of the singleton variable used
487 487
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 
490 490
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
491 491
         //The work to be done here is to bind the classes to be included in the console share privately.
492
-        $this->consoleShared($object,$callback);
492
+        $this->consoleShared($object, $callback);
493 493
 
494 494
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
495 495
         //Otherwise, when the bind object and callback are sent, the closure class inherits
496 496
         //the applicationProvider object and the resolve method is called
497
-        return ($object===null) ? $this->kernel() : $this->build($object,$callback);
497
+        return ($object===null) ? $this->kernel() : $this->build($object, $callback);
498 498
 
499 499
     }
500 500
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      */
515 515
     public function singleton()
516 516
     {
517
-        if($this->singleton===false){
517
+        if ($this->singleton===false) {
518 518
 
519 519
             //after first initializing, the singleton variable is set to true,
520 520
             //and subsequent incoming classes can inherit the loaded object.
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
         // for application instance
536 536
         // if the values ​​to be saved are to be saved without the concrete,
537 537
         // if it is an array.
538
-        if($this->values['concrete']===null) {
538
+        if ($this->values['concrete']===null) {
539 539
 
540 540
             // Without concrete,
541 541
             // the saved value will be saved
542 542
             // if the it does not exist in application instance.
543
-            if(!isset($instance->{$this->values['key']})) {
543
+            if (!isset($instance->{$this->values['key']})) {
544 544
                 $this->registerProcess($instance);
545 545
             }
546 546
             return false;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 
549 549
         // We send concrete values to be recorded with concrete as true.
550 550
         // these values will be recorded as a array.
551
-        $this->registerProcess($instance,true);
551
+        $this->registerProcess($instance, true);
552 552
     }
553 553
 
554 554
     /**
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
      * @param null|string $object
557 557
      * @return mixed
558 558
      */
559
-    public function terminate($key,$object=null)
559
+    public function terminate($key, $object = null)
560 560
     {
561 561
         // object null is
562 562
         // sent to just terminate a key.
563
-        if($object===null){
563
+        if ($object===null) {
564 564
             unset(core()->{$key});
565 565
             unset($this->singleton()->{$key});
566 566
             return false;
Please login to merge, or discard this patch.