Test Setup Failed
Push β€” master ( 924bf3...4497b0 )
by Php Easy Api
19:55 queued 45s
created
src/resta/Container/Container.php 1 patch
Spacing   +52 added lines, -52 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,10 +208,10 @@  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){
211
+        foreach (explode(".", $abstract) as $item) {
212 212
             $container = $container[$item];
213 213
 
214
-            if(is_null($container)){
214
+            if (is_null($container)) {
215 215
                 return null;
216 216
             }
217 217
         }
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 
235 235
         // the has method can have a dotted string value so
236 236
         // we need to be able to control the string or array within the container.
237
-        foreach (explode(".",$abstract) as $item){
237
+        foreach (explode(".", $abstract) as $item) {
238 238
 
239 239
             // this blog will work
240 240
             // if the data in the container loop points to an array.
241
-            if(!is_array($container)){
241
+            if (!is_array($container)) {
242 242
 
243 243
                 // we are querying the value of
244 244
                 // the items corresponding to the dotted value in the container.
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                 $container = $container[$item];
247 247
                 $bools[] = is_null($container) ? false : true;
248 248
             }
249
-            else{
249
+            else {
250 250
 
251 251
                 // if the container array corresponds to a string,
252 252
                 // the bools array is filled with the isset control directly.
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
         // the method returns false if the bools sequence is false,
258 258
         // otherwise it will return true.
259
-        return in_array(false,$bools) ? false : true;
259
+        return in_array(false, $bools) ? false : true;
260 260
     }
261 261
 
262 262
     /**
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      * @throws DependencyException
307 307
      * @throws NotFoundException
308 308
      */
309
-    public function make($object=null,$callback=null,$container=false)
309
+    public function make($object = null, $callback = null, $container = false)
310 310
     {
311 311
         //we check whether the boolean value of the singleton variable used
312 312
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 
315 315
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
316 316
         //The work to be done here is to bind the classes to be included in the console share privately.
317
-        if($container){
318
-            $this->consoleShared($object,$callback);
317
+        if ($container) {
318
+            $this->consoleShared($object, $callback);
319 319
         }
320 320
 
321 321
         //If the third parameter passed to the bind method carries a container value,
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
326 326
         //Otherwise, when the bind object and callback are sent, the closure class inherits
327 327
         //the applicationProvider object and the resolve method is called
328
-        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object,$callback);
328
+        return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object, $callback);
329 329
     }
330 330
 
331 331
     /**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      */
346 346
     public function offsetGet($offset) {
347 347
 
348
-        return $this->resolve($this->instances['containerInstanceResolve'],[
348
+        return $this->resolve($this->instances['containerInstanceResolve'], [
349 349
             'instances' => $this->instances
350 350
         ])->{$offset}();
351 351
     }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * @param null $concrete
370 370
      * @return bool|mixed
371 371
      */
372
-    public function register($key,$object,$concrete=null)
372
+    public function register($key, $object, $concrete = null)
373 373
     {
374 374
         // we assign the values ​​required
375 375
         // for register to the global value variable.
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
         // If there is an instance of the application class,
381 381
         // the register method is saved both in this example and in the global.
382
-        if(defined('appInstance')){
382
+        if (defined('appInstance')) {
383 383
 
384 384
             // where we will assign both the global instance
385 385
             // and the registered application object.
@@ -398,19 +398,19 @@  discard block
 block discarded – undo
398 398
      * @param bool $withConcrete
399 399
      * @return bool
400 400
      */
401
-    private function registerProcess($instance,$withConcrete=false)
401
+    private function registerProcess($instance, $withConcrete = false)
402 402
     {
403 403
         // values recorded without concrete.
404 404
         // or values deleted
405
-        if(false===$withConcrete){
405
+        if (false===$withConcrete) {
406 406
 
407 407
             //values registered without concrete
408
-            $instance->{$this->values['key']}=$this->values['object'];
408
+            $instance->{$this->values['key']} = $this->values['object'];
409 409
             return false;
410 410
         }
411 411
 
412 412
         //values registered with concrete
413
-        $instance->{$this->values['key']}[$this->values['object']]=$this->values['concrete'];
413
+        $instance->{$this->values['key']}[$this->values['object']] = $this->values['concrete'];
414 414
     }
415 415
 
416 416
     /**
@@ -421,22 +421,22 @@  discard block
 block discarded – undo
421 421
      * @throws DependencyException
422 422
      * @throws NotFoundException
423 423
      */
424
-    public function resolve($class,$bind=array())
424
+    public function resolve($class, $bind = array())
425 425
     {
426 426
         //the context bind objects are checked again and the bind sequence submitted by
427 427
         //the user is checked and forced to re-instantiate the object.
428
-        $this->contextualBindCleaner($class,$bind);
428
+        $this->contextualBindCleaner($class, $bind);
429 429
 
430 430
         //We do an instance check to get the static instance values of
431 431
         //the classes to be resolved with the make bind method.
432
-        if(!isset(self::$instance[$class])){
432
+        if (!isset(self::$instance[$class])) {
433 433
 
434 434
             //bind params object
435 435
             self::$bindParams[$class] = $bind;
436 436
 
437 437
             //By singleton checking, we solve the dependency injection of the given class.
438 438
             //Thus, each class can be called together with its dependency.
439
-            self::$instance[$class] = DIContainerManager::make($class,$this->applicationProviderBinding($this,self::$bindParams[$class]));
439
+            self::$instance[$class] = DIContainerManager::make($class, $this->applicationProviderBinding($this, self::$bindParams[$class]));
440 440
             $this->singleton()->resolved[$class] = self::$instance[$class];
441 441
 
442 442
             //return resolve class
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
      * @param $class
455 455
      * @return mixed
456 456
      */
457
-    public function resolved($class){
457
+    public function resolved($class) {
458 458
 
459
-        if(isset($this['resolved'][$class])){
459
+        if (isset($this['resolved'][$class])) {
460 460
             return $this['resolved'][$class];
461 461
         }
462 462
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
      * @throws DependencyException
472 472
      * @throws NotFoundException
473 473
      */
474
-    public function share($object=null,$callback=null)
474
+    public function share($object = null, $callback = null)
475 475
     {
476 476
         //we check whether the boolean value of the singleton variable used
477 477
         //for booting does not reset every time the object variable to be assigned to the kernel variable is true
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 
480 480
         //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound.
481 481
         //The work to be done here is to bind the classes to be included in the console share privately.
482
-        $this->consoleShared($object,$callback);
482
+        $this->consoleShared($object, $callback);
483 483
 
484 484
         //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object.
485 485
         //Otherwise, when the bind object and callback are sent, the closure class inherits
486 486
         //the applicationProvider object and the resolve method is called
487
-        return ($object===null) ? $this->kernel() : $this->build($object,$callback);
487
+        return ($object===null) ? $this->kernel() : $this->build($object, $callback);
488 488
 
489 489
     }
490 490
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
      */
505 505
     public function singleton()
506 506
     {
507
-        if($this->singleton===false){
507
+        if ($this->singleton===false) {
508 508
 
509 509
             //after first initializing, the singleton variable is set to true,
510 510
             //and subsequent incoming classes can inherit the loaded object.
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
         // for application instance
526 526
         // if the values ​​to be saved are to be saved without the concrete,
527 527
         // if it is an array.
528
-        if($this->values['concrete']===null) {
528
+        if ($this->values['concrete']===null) {
529 529
 
530 530
             // Without concrete,
531 531
             // the saved value will be saved
532 532
             // if the it does not exist in application instance.
533
-            if(!isset($instance->{$this->values['key']})) {
533
+            if (!isset($instance->{$this->values['key']})) {
534 534
                 $this->registerProcess($instance);
535 535
             }
536 536
             return false;
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
         // We send concrete values to be recorded with concrete as true.
540 540
         // these values will be recorded as a array.
541
-        $this->registerProcess($instance,true);
541
+        $this->registerProcess($instance, true);
542 542
     }
543 543
 
544 544
     /**
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
      * @param null|string $object
547 547
      * @return mixed
548 548
      */
549
-    public function terminate($key,$object=null)
549
+    public function terminate($key, $object = null)
550 550
     {
551 551
         // object null is
552 552
         // sent to just terminate a key.
553
-        if($object===null){
553
+        if ($object===null) {
554 554
             unset(core()->{$key});
555 555
             unset($this->singleton()->{$key});
556 556
             return false;
Please login to merge, or discard this patch.