| Total Complexity | 9 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | final class StorageManager |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var StorageService[] |
||
| 23 | */ |
||
| 24 | private $storages = []; |
||
| 25 | |||
| 26 | public function addStorage(string $name, StorageService $storage): void |
||
| 27 | { |
||
| 28 | $this->storages[$name] = $storage; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param string|string[]|null $name |
||
| 33 | */ |
||
| 34 | public function getStorage($name = null): ?StorageService |
||
| 35 | { |
||
| 36 | if (empty($name)) { |
||
| 37 | return $this->getStorage('default'); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (isset($this->storages[$name])) { |
||
| 41 | return $this->storages[$name]; |
||
| 42 | } |
||
| 43 | |||
| 44 | if ('default' === $name) { |
||
| 45 | $name = $this->getFirstName(); |
||
| 46 | if (isset($this->storages[$name])) { |
||
| 47 | return $this->storages[$name]; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | return null; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function getFirstName(): ?string |
||
| 61 | } |
||
| 62 | |||
| 63 | public function getNames(): array |
||
| 66 | } |
||
| 67 | } |
||
| 68 |