[Cache] Check if class is instantiable
This commit is contained in:
parent
6e70d461e1
commit
1b34d9860e
1 changed files with 6 additions and 2 deletions
|
@ -61,7 +61,7 @@ class Cache {
|
||||||
* @throws \Exception if the requested cache file doesn't exist in the
|
* @throws \Exception if the requested cache file doesn't exist in the
|
||||||
* working directory.
|
* working directory.
|
||||||
* @param string $name Name of the cache object.
|
* @param string $name Name of the cache object.
|
||||||
* @return object The cache object.
|
* @return object|bool The cache object or false if the class is not instantiable.
|
||||||
*/
|
*/
|
||||||
public static function create($name){
|
public static function create($name){
|
||||||
if(!self::isCacheName($name)) {
|
if(!self::isCacheName($name)) {
|
||||||
|
@ -76,9 +76,13 @@ class Cache {
|
||||||
|
|
||||||
require_once $filePath;
|
require_once $filePath;
|
||||||
|
|
||||||
|
if((new \ReflectionClass($name))->isInstantiable()) {
|
||||||
return new $name();
|
return new $name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the working directory.
|
* Sets the working directory.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue