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

Commit b82925b

Browse files
committed
Added ability to get an adapter instance from the storage class
1 parent 0a63b13 commit b82925b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Dmyers/Storage/Storage.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,24 @@ public static function instance($name = null)
3737
$name = static::config('default', 'Local');
3838
}
3939

40+
$adapter = static::adapter($name);
41+
42+
$instance = new static();
43+
$instance->setAdapter($adapter);
44+
45+
return $instance;
46+
}
47+
48+
public static function adapter($name)
49+
{
4050
$adapter = 'Dmyers\\Storage\\Adapter\\'.$name;
4151

4252
if (!class_exists($adapter)) {
4353
throw new \InvalidArgumentException("Storage adapter {$name} does not exist.");
4454
}
4555

46-
$instance = new static();
4756
$adapter = new $adapter();
48-
$instance->setAdapter($adapter);
4957

50-
return $instance;
58+
return $adapter;
5159
}
5260
}

0 commit comments

Comments
 (0)