forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactory.php
More file actions
64 lines (53 loc) · 1.17 KB
/
Copy pathFactory.php
File metadata and controls
64 lines (53 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace PHPCensor\Store;
use PHPCensor\Store;
class Factory
{
/**
* @var Factory
*/
protected static $instance;
/**
* A collection of the stores currently loaded by the factory.
*
* @var Store[]
*/
protected $loadedStores = [];
/**
* @return Factory
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* @param string $storeName Store name (should match a model name).
*
* @return Store
*/
public static function getStore($storeName)
{
$factory = self::getInstance();
return $factory->loadStore($storeName);
}
protected function __construct()
{
}
/**
* @param string $store
*
* @return Store;
*/
public function loadStore($store)
{
if (!isset($this->loadedStores[$store])) {
$class = 'PHPCensor\\Store\\' . $store . 'Store';
$obj = new $class();
$this->loadedStores[$store] = $obj;
}
return $this->loadedStores[$store];
}
}