This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
5
{
6
const DRIVER_RAM = 'Ram';
7
const DRIVER_FILE = 'File';
8
const DRIVER_SHM = 'Shm';
9
private static $instance;
10
11
/**
12
* @codeCoverageIgnore
13
*/
14
private function __construct()
15
{
16
}
17
18
/**
19
* @codeCoverageIgnore
20
*/
21
private function __clone()
22
{
23
}
24
25
/**
26
* @return self
27
*/
28
4
final public static function getInstance()
29
{
30
4
if (!self::$instance) {
31
1
$class = get_called_class();
32
1
self::$instance = new $class();
33
}
34
4
return self::$instance;
35
}
36
37
/**
38
* @param string $driver
39
* @param array $params
40
* @return CacheInterface
41
* @throws Exception
42
*/
43
3
final public function create($driver = self::DRIVER_RAM, $params = array())
44
{
45
3
$class = $this->getClassForName($driver);
46
3
if (!class_exists($class)) {
47
2
throw new Exception('Unable to create ' . $class);
48
}
49
2
$instance = new $class($params);
50
2
if (!$instance instanceof CacheInterface) {
51
1
throw new Exception('Unable to create ' . $class);
52
}
53
2
return $instance;
54
}
55
56
/**
57
* Must return full class name for specified driver name
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.