| Total Complexity | 7 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class CacheFactory |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param string $name The name of the cache object to make. |
||
| 15 | * @param array $config Options to use when constructing the cache. |
||
| 16 | * |
||
| 17 | * @return CacheInterface |
||
| 18 | */ |
||
| 19 | public static function make(string $name, array $config) : CacheInterface |
||
| 20 | { |
||
| 21 | if ($name === MongoCache::class) { |
||
| 22 | return self::getMongoCache($config); |
||
| 23 | } |
||
| 24 | |||
| 25 | if ($name === InMemoryCache::class) { |
||
| 26 | return new InMemoryCache(); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($name === NullCache::class) { |
||
| 30 | return new NullCache(); |
||
| 31 | } |
||
| 32 | |||
| 33 | throw new \RuntimeException("Cannot create cache instance of '{$name}'"); |
||
| 34 | } |
||
| 35 | |||
| 36 | private static function getMongoCache(array $config) : MongoCache |
||
| 39 | } |
||
| 40 | |||
| 41 | private static function getMongoCollectionFromConfig(array $config) : MongoDB\Collection |
||
| 53 |