Completed
Push — master ( 9bf308...234a08 )
by Tobias
161:07 queued 125:55
created

StorageTrait::getStorage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 1
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
16
trait StorageTrait
17
{
18
    /**
19
     * @var StorageManager
20
     */
21
    private $storageManager;
22
23
    private function getStorage($configName)
24
    {
25
        if (null === $storage = $this->storageManager->getStorage($configName)) {
26
            $availableStorages = $this->storageManager->getNames();
27
28
            throw new \InvalidArgumentException(sprintf('Unknown storage "%s". Available storages are "%s".', $configName, implode('", "', $availableStorages)));
29
        }
30
    }
31
}
32