Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 84.62% |
Changes | 0 |
1 | <?php |
||
15 | trait TStorage |
||
16 | { |
||
17 | /** |
||
18 | * Set another storage than usually called local volume |
||
19 | * @param object|array<string, string|object>|string $storageParams |
||
20 | * @throws MapperException |
||
21 | */ |
||
22 | 17 | protected function setStorage($storageParams = 'volume'): void |
|
23 | { |
||
24 | try { |
||
25 | 17 | $instance = StorageSingleton::getInstance(); |
|
26 | 17 | $instance->clearStorage(); |
|
27 | 17 | $instance->getStorage($storageParams); |
|
28 | 1 | } catch (StorageException $ex) { |
|
29 | 1 | throw new MapperException($ex->getMessage(), $ex->getCode(), $ex); |
|
30 | } |
||
31 | 16 | } |
|
32 | |||
33 | /** |
||
34 | * @throws MapperException |
||
35 | * @return IStorage |
||
36 | */ |
||
37 | 14 | protected function getStorage(): IStorage |
|
38 | { |
||
39 | try { |
||
40 | 14 | return StorageSingleton::getInstance()->getStorage('volume'); |
|
41 | // @codeCoverageIgnoreStart |
||
42 | } catch (StorageException $ex) { |
||
43 | // means you have failed storage - larger problem than "only" unknown storage |
||
44 | throw new MapperException($ex->getMessage(), $ex->getCode(), $ex); |
||
45 | } |
||
46 | // @codeCoverageIgnoreEnd |
||
47 | } |
||
48 | |||
49 | 1 | protected function clearStorage(): void |
|
52 | 1 | } |
|
53 | } |
||
54 |