@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * because it is aways needed. |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | -require_once __DIR__ . '/ContainerInterface.php'; |
|
| 21 | +require_once __DIR__.'/ContainerInterface.php'; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * The container class is reponsable to construct all objects |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | // creating a resolving callback that in every call will recalculate all dependencies |
| 126 | 126 | // for the given class, and offcourse, using a cached resolving callback if exists. |
| 127 | 127 | |
| 128 | - return function (string $abstract, array $parameters) use ($inspector, $dependencies) { |
|
| 128 | + return function(string $abstract, array $parameters) use ($inspector, $dependencies) { |
|
| 129 | 129 | return $inspector->newInstanceArgs( |
| 130 | 130 | $this->process($abstract, $parameters, $dependencies) |
| 131 | 131 | ); |
| 132 | 132 | }; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return function (string $abstract) { |
|
| 135 | + return function(string $abstract) { |
|
| 136 | 136 | return new $abstract; |
| 137 | 137 | }; |
| 138 | 138 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | { |
| 174 | 174 | $key = $abstract.$dependency->name; |
| 175 | 175 | |
| 176 | - if (! isset($this->resolved[$key])) { |
|
| 176 | + if (!isset($this->resolved[$key])) { |
|
| 177 | 177 | $this->resolved[$key] = $this->generate($abstract, $dependency); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | try { |
| 200 | 200 | $value = $dependency->getDefaultValue(); |
| 201 | 201 | |
| 202 | - return function () use ($value) { |
|
| 202 | + return function() use ($value) { |
|
| 203 | 203 | return $value; |
| 204 | 204 | }; |
| 205 | 205 | } catch (ReflectionException $e) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | return $this->dependencies[$entry]; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return function () use ($classname) { |
|
| 225 | + return function() use ($classname) { |
|
| 226 | 226 | return $this->make($classname); |
| 227 | 227 | }; |
| 228 | 228 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | public function get($abstract) |
| 257 | 257 | { |
| 258 | - if (! isset($this->collection[$abstract])) { |
|
| 258 | + if (!isset($this->collection[$abstract])) { |
|
| 259 | 259 | throw new NotFoundException("Element '$abstract' not found"); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | if ($concrete instanceof Closure === false) { |
| 330 | - $concrete = function (Container $container) use ($concrete) { |
|
| 330 | + $concrete = function(Container $container) use ($concrete) { |
|
| 331 | 331 | return $container->make($concrete); |
| 332 | 332 | }; |
| 333 | 333 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | public function setIf(string $abstract, $concrete, bool $shared = false) : ContainerInterface |
| 353 | 353 | { |
| 354 | - if (! isset($this->collection[$abstract])) { |
|
| 354 | + if (!isset($this->collection[$abstract])) { |
|
| 355 | 355 | $this->set($abstract, $concrete, $shared); |
| 356 | 356 | } |
| 357 | 357 | |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | { |
| 373 | 373 | if ($dependency instanceof Closure === false) { |
| 374 | 374 | if (is_object($dependency)) { |
| 375 | - $dependency = function () use ($dependency) { |
|
| 375 | + $dependency = function() use ($dependency) { |
|
| 376 | 376 | return $dependency; |
| 377 | 377 | }; |
| 378 | 378 | } else { |
| 379 | - $dependency = function () use ($dependency) { |
|
| 379 | + $dependency = function() use ($dependency) { |
|
| 380 | 380 | return $this->get($dependency); |
| 381 | 381 | }; |
| 382 | 382 | } |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | |
| 417 | 417 | public function instance(string $abstract, $instance) : ContainerInterface |
| 418 | 418 | { |
| 419 | - if (! is_object($instance)) { |
|
| 420 | - throw new ContainerException('Trying to store ' . gettype($instance) . ' as object.'); |
|
| 419 | + if (!is_object($instance)) { |
|
| 420 | + throw new ContainerException('Trying to store '.gettype($instance).' as object.'); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $this->collection[$abstract] = $instance; |
@@ -437,14 +437,14 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | public function extend(string $abstract, closure $extension) : ContainerInterface |
| 439 | 439 | { |
| 440 | - if (! isset($this->collection[$abstract])) { |
|
| 440 | + if (!isset($this->collection[$abstract])) { |
|
| 441 | 441 | throw new NotFoundException($abstract); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | $object = $this->collection[$abstract]; |
| 445 | 445 | |
| 446 | 446 | if ($object instanceof Closure) { |
| 447 | - $this->collection[$abstract] = function () use ($object, $extension) { |
|
| 447 | + $this->collection[$abstract] = function() use ($object, $extension) { |
|
| 448 | 448 | return $extension($object($this), $this); |
| 449 | 449 | }; |
| 450 | 450 | } else { |
@@ -467,11 +467,11 @@ discard block |
||
| 467 | 467 | |
| 468 | 468 | public function share(string $abstract) : ContainerInterface |
| 469 | 469 | { |
| 470 | - if (! isset($this->collection[$abstract])) { |
|
| 470 | + if (!isset($this->collection[$abstract])) { |
|
| 471 | 471 | throw new NotFoundException("Element '$abstract' not found"); |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if (! $this->collection[$abstract] instanceof Closure) { |
|
| 474 | + if (!$this->collection[$abstract] instanceof Closure) { |
|
| 475 | 475 | throw new ContainerException("'$abstract' must be a resolvable element"); |
| 476 | 476 | } |
| 477 | 477 | |