summaryrefslogtreecommitdiff
path: root/src/Container/Container.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Container/Container.php')
-rw-r--r--src/Container/Container.php35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/Container/Container.php b/src/Container/Container.php
index df2f92fe..9af5c1e6 100644
--- a/src/Container/Container.php
+++ b/src/Container/Container.php
@@ -49,6 +49,17 @@ class Container implements ContainerInterface
*/
public function instance($abstract, $instance)
{
+ $this->singleton($abstract, $instance);
+ }
+
+ /**
+ * Register a shared entry as singleton in the container
+ *
+ * @param string $abstract
+ * @param mixed $instance
+ */
+ public function singleton($abstract, $instance)
+ {
$this->instances[$abstract] = $instance;
}
@@ -69,9 +80,20 @@ class Container implements ContainerInterface
}
/**
+ * Resolve the requested object
+ *
+ * @param string $abstract
+ * @return mixed
+ */
+ protected function resolve($abstract)
+ {
+ return $this->instances[$abstract];
+ }
+
+ /**
* Get the globally available instance of the container
*
- * @return Container
+ * @return self
*/
public static function getInstance()
{
@@ -91,15 +113,4 @@ class Container implements ContainerInterface
{
static::$instance = $container;
}
-
- /**
- * Resolve the requested object
- *
- * @param string $abstract
- * @return mixed
- */
- protected function resolve($abstract)
- {
- return $this->instances[$abstract];
- }
}