From 0ac981876432ff8f7f76ffee8c5102b633d760d4 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 19 Sep 2017 14:50:20 +0200 Subject: Added Application --- src/Container/Container.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/Container/Container.php') 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 @@ -48,6 +48,17 @@ class Container implements ContainerInterface * @param mixed $instance Entry */ 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; } @@ -68,10 +79,21 @@ class Container implements ContainerInterface return isset($this->instances[$id]); } + /** + * 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]; - } } -- cgit v1.2.3-54-g00ecf