From b82925bb2cc02bcf59ca65aaea6cd672fe1f8d6c Mon Sep 17 00:00:00 2001 From: Derek Myers Date: Tue, 27 May 2014 20:11:36 -0500 Subject: [PATCH] Added ability to get an adapter instance from the storage class --- src/Dmyers/Storage/Storage.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Dmyers/Storage/Storage.php b/src/Dmyers/Storage/Storage.php index f23c6c9..7e563e3 100644 --- a/src/Dmyers/Storage/Storage.php +++ b/src/Dmyers/Storage/Storage.php @@ -37,16 +37,24 @@ public static function instance($name = null) $name = static::config('default', 'Local'); } + $adapter = static::adapter($name); + + $instance = new static(); + $instance->setAdapter($adapter); + + return $instance; + } + + public static function adapter($name) + { $adapter = 'Dmyers\\Storage\\Adapter\\'.$name; if (!class_exists($adapter)) { throw new \InvalidArgumentException("Storage adapter {$name} does not exist."); } - $instance = new static(); $adapter = new $adapter(); - $instance->setAdapter($adapter); - return $instance; + return $adapter; } } \ No newline at end of file