Total Complexity | 7 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait StorageConfigTrait |
||
13 | { |
||
14 | /** |
||
15 | * Build storage config by provided servers and buckets |
||
16 | * If no buckets were defined it will be built for each defined server |
||
17 | * |
||
18 | * @param array|null $servers |
||
19 | * @param array|null $buckets |
||
20 | * |
||
21 | * @return StorageConfig |
||
22 | * |
||
23 | * @throws ConfigException |
||
24 | */ |
||
25 | protected function buildStorageConfig(?array $servers = null, ?array $buckets = null): StorageConfig |
||
26 | { |
||
27 | if (empty($servers)) { |
||
28 | $servers[self::SERVER_NAME] = [ |
||
|
|||
29 | LocalInfo::ADAPTER_KEY => LocalFilesystemAdapter::class, |
||
30 | LocalInfo::OPTIONS_KEY => [ |
||
31 | LocalInfo::ROOT_DIR_KEY => self::ROOT_DIR, |
||
32 | LocalInfo::HOST_KEY => self::CONFIG_HOST, |
||
33 | ], |
||
34 | ]; |
||
35 | } |
||
36 | |||
37 | if (!empty($servers) && empty($buckets)) { |
||
38 | $buckets = []; |
||
39 | foreach ($servers as $server => $serverInfo) { |
||
40 | $buckets[$this->buildBucketNameByServer($server)] = $this->buildServerBucketInfoDesc($server); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return new StorageConfig([ |
||
45 | 'servers' => $servers, |
||
46 | 'buckets' => $buckets |
||
47 | ]); |
||
48 | } |
||
49 | |||
50 | protected function buildServerBucketInfoDesc(string $serverName): array |
||
55 | ]; |
||
56 | } |
||
57 | |||
58 | protected function buildBucketNameByServer(string $server): string |
||
61 | } |
||
62 | } |
||
63 |