diff --git a/docs/class-Deimos.DI.ContainerEmpty.html b/docs/class-Deimos.DI.ContainerEmpty.html
index 5eca35c..86946d4 100644
--- a/docs/class-Deimos.DI.ContainerEmpty.html
+++ b/docs/class-Deimos.DI.ContainerEmpty.html
@@ -182,11 +182,11 @@
Direct known subclasses
callback(),
get(),
getFirst(),
+ getInstance(),
group(),
instance(),
path(),
steps(),
- storage(),
value()
diff --git a/docs/class-Deimos.DI.DI.html b/docs/class-Deimos.DI.DI.html
index 6988c50..b444a81 100644
--- a/docs/class-Deimos.DI.DI.html
+++ b/docs/class-Deimos.DI.DI.html
@@ -121,7 +121,7 @@ Indirect known subclasses
Namespace: Deimos\DI
- Located at DI/DI.php
+ Located at DI/DI.php
@@ -279,7 +279,7 @@ Parameters
-
+
protected
@@ -290,8 +290,8 @@ Parameters
|
- #
- storage( $name )
+ #
+ build( $name, callable $callback )
@@ -309,7 +309,7 @@ Parameters
|
-
+
protected
@@ -320,8 +320,8 @@ Parameters
|
- #
- build( $name, callable $callback )
+ #
+ path( $name )
@@ -339,7 +339,7 @@ Parameters
|
-
+
protected
@@ -350,8 +350,8 @@ Parameters
|
- #
- path( $name )
+ #
+ getFirst( & $path )
@@ -369,10 +369,10 @@ Parameters
|
-
+
- protected
+ public
@@ -380,8 +380,8 @@ Parameters
|
- #
- getFirst( & $path )
+ #
+ get( $name )
@@ -399,10 +399,10 @@ Parameters
|
-
+
- public
+ protected
@@ -410,8 +410,8 @@ Parameters
|
- #
- get( $name )
+ #
+ getInstance( $row )
@@ -441,7 +441,7 @@ Parameters
#
- __call( $name, array $arguments = [] )
+ __call( $name, array $arguments = [] )
@@ -482,7 +482,7 @@ Returns
#
- value( $name, $row, array $arguments = [] )
+ value( $name, $row, array $arguments = [] )
@@ -521,7 +521,7 @@ Parameters
#
- callback( $name, $callback )
+ callback( $name, $callback )
@@ -558,7 +558,7 @@ Parameters
#
- instance( $name, $class, array $arguments = [] )
+ instance( $name, $class, array $arguments = [] )
@@ -588,7 +588,7 @@ Parameters
#
- configure( )
+ configure( )
configure
diff --git a/docs/class-Deimos.DI.Group.html b/docs/class-Deimos.DI.Group.html
index 2b75d39..b8c9d63 100644
--- a/docs/class-Deimos.DI.Group.html
+++ b/docs/class-Deimos.DI.Group.html
@@ -199,11 +199,11 @@ Overrides
callback(),
get(),
getFirst(),
+ getInstance(),
group(),
instance(),
path(),
steps(),
- storage(),
value()
|
| | | | |
diff --git a/docs/source-class-Deimos.DI.DI.html b/docs/source-class-Deimos.DI.DI.html
index 0e459f9..409d583 100644
--- a/docs/source-class-Deimos.DI.DI.html
+++ b/docs/source-class-Deimos.DI.DI.html
@@ -180,116 +180,109 @@ Classes
84: }
85: }
86:
- 87: protected function storage($name)
+ 87: protected function build($name, callable $callback)
88: {
- 89: if ($this->self->storage[$name] instanceof Instance)
- 90: {
- 91: 92: 93:
- 94: $instance = $this->self->storage[$name];
- 95:
- 96: $value = $instance->get();
- 97: unset($this->self->storage[$name]);
- 98:
- 99: $this->self->storage[$name] = $value;
-100: }
+ 89: $this->value($name, $callback);
+ 90: }
+ 91:
+ 92: protected function path($name)
+ 93: {
+ 94: return explode('.', $name);
+ 95: }
+ 96:
+ 97: protected function getFirst(&$path)
+ 98: {
+ 99: $name = array_shift($path);
+100: $object = $this->self->storage[$name];
101:
-102: return $this->self->storage[$name];
+102: return $this->getInstance($object);
103: }
104:
-105: protected function build($name, callable $callback)
+105: public function get($name)
106: {
-107: $this->value($name, $callback);
-108: }
-109:
-110: protected function path($name)
-111: {
-112: return explode('.', $name);
-113: }
-114:
-115: protected function getFirst(&$path)
-116: {
-117: $name = array_shift($path);
-118:
-119: return $this->storage($name);
-120: }
-121:
-122: public function get($name)
-123: {
-124: $path = $this->path($name);
-125: $row = $this->getFirst($path);
-126: $last = array_pop($path);
-127:
-128: if (!empty($path))
-129: {
-130: $this->steps($row, $path);
-131: }
-132:
-133: if ($last && is_object($row))
-134: {
-135: if ($row instanceof self)
-136: {
-137: return $row->self->storage[$last];
-138: }
-139:
-140: return $row->{$last}();
-141: }
-142:
-143: return $row;
-144: }
-145:
-146: 147: 148: 149: 150: 151:
-152: public function __call($name, array $arguments = [])
-153: {
-154: return $this->call($name, $arguments);
-155: }
-156:
-157: 158: 159: 160: 161:
-162: protected function value($name, $row, array $arguments = [])
-163: {
-164: $argument = new Argument($this, $arguments);
-165: $arguments = $argument->get();
-166: unset($argument);
-167:
-168: $this->self->storage[$name] =
-169: is_callable($row) ?
-170: call_user_func_array($row, $arguments) : $row;
-171: }
-172:
-173: 174: 175: 176:
-177: protected function callback($name, $callback)
-178: {
-179: $this->self->storage[$name] = $callback;
-180: }
-181:
-182: protected function instance($name, $class, array $arguments = [])
-183: {
-184: $this->self->storage[$name] = new Instance(
-185: $this,
-186: $class,
-187: new Argument($this, $arguments)
-188: );
-189: }
-190:
-191: 192: 193:
-194: abstract protected function configure();
-195:
-196: }
+107: $path = $this->path($name);
+108: $row = $this->getFirst($path);
+109: $last = array_pop($path);
+110:
+111: if (!empty($path))
+112: {
+113: $this->steps($row, $path);
+114: }
+115:
+116: if ($last && is_object($row))
+117: {
+118: if ($row instanceof self)
+119: {
+120: return $this->getInstance($row->self->storage[$last]);
+121: }
+122:
+123: $row = $row->{$last}();
+124: }
+125:
+126: return $this->getInstance($row);
+127: }
+128:
+129: protected function getInstance($row)
+130: {
+131: if ($row instanceof Instance)
+132: {
+133: return $row->get();
+134: }
+135:
+136: return $row;
+137: }
+138:
+139: 140: 141: 142: 143: 144:
+145: public function __call($name, array $arguments = [])
+146: {
+147: return $this->call($name, $arguments);
+148: }
+149:
+150: 151: 152: 153: 154:
+155: protected function value($name, $row, array $arguments = [])
+156: {
+157: $argument = new Argument($this, $arguments);
+158: $arguments = $argument->get();
+159: unset($argument);
+160:
+161: $this->self->storage[$name] =
+162: is_callable($row) ?
+163: call_user_func_array($row, $arguments) : $row;
+164: }
+165:
+166: 167: 168: 169:
+170: protected function callback($name, $callback)
+171: {
+172: $this->self->storage[$name] = $callback;
+173: }
+174:
+175: protected function instance($name, $class, array $arguments = [])
+176: {
+177: $this->self->storage[$name] = new Instance(
+178: $this,
+179: $class,
+180: new Argument($this, $arguments)
+181: );
+182: }
+183:
+184: 185: 186:
+187: abstract protected function configure();
+188:
+189: }