1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the PHP Translation package. |
||
5 | * |
||
6 | * (c) PHP Translation team <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Translation\Bundle\Command; |
||
13 | |||
14 | use Translation\Bundle\Service\StorageManager; |
||
15 | use Translation\Bundle\Service\StorageService; |
||
16 | |||
17 | trait StorageTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var StorageManager |
||
21 | */ |
||
22 | private $storageManager; |
||
23 | |||
24 | /** |
||
25 | * @param string|string[]|null $configName |
||
26 | * |
||
27 | * @throws \InvalidArgumentException |
||
28 | */ |
||
29 | private function getStorage($configName): StorageService |
||
30 | { |
||
31 | if (null === $storage = $this->storageManager->getStorage($configName)) { |
||
32 | $availableStorages = $this->storageManager->getNames(); |
||
33 | |||
34 | throw new \InvalidArgumentException(\sprintf('Unknown storage "%s". Available storages are "%s".', $configName, \implode('", "', $availableStorages))); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
35 | } |
||
36 | |||
37 | return $storage; |
||
38 | } |
||
39 | } |
||
40 |