Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Added ability to get an adapter instance from the storage class
Browse files Browse the repository at this point in the history
  • Loading branch information
dmyers committed May 28, 2014
1 parent 0a63b13 commit b82925b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Dmyers/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit b82925b

Please sign in to comment.