| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 5 | public function create(string $cachePoolName): CacheItemPoolInterface |
|
| 31 | { |
||
| 32 | 5 | $types = []; |
|
| 33 | 5 | $configuration = $this->cachePluginConfiguration->getPoolConfiguration($cachePoolName); |
|
| 34 | 5 | $adapterType = $configuration->getAdapterType(); |
|
| 35 | 5 | foreach ($this->cacheConcreteAdapterFactoryCollection as $factory) { |
|
| 36 | 5 | $type = $factory->type(); |
|
| 37 | 5 | if ($type === $adapterType) { |
|
| 38 | 4 | return $factory->create($configuration); |
|
| 39 | } |
||
| 40 | 5 | $types[] = $type; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | $errorMessage = sprintf( |
|
| 44 | 1 | 'Can not initialize cache pool `%s`. Adapter type `%s` is not supported. Available types: %s', |
|
| 45 | 1 | $cachePoolName, |
|
| 46 | 1 | $adapterType, |
|
| 47 | 1 | implode(', ', $types) |
|
| 48 | 1 | ); |
|
| 49 | |||
| 50 | 1 | throw new \InvalidArgumentException($errorMessage); |
|
| 51 | } |
||
| 53 |