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