Passed
Push — master ( 9db0c6...cf0e90 )
by Michal
18:17 queued 01:02
created

CheckDictionariesConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Efabrica\TranslationsAutomatization\Command\CheckDictionaries;
4
5
use Efabrica\TranslationsAutomatization\Storage\StorageInterface;
6
7
class CheckDictionariesConfig
8
{
9
    /** @var array<string, StorageInterface[]> */
10
    private $dictionaryStorages;
11
12
    /**
13
     * @param array<string, StorageInterface[]> $dictionaryStorages
14
     */
15
    public function __construct(array $dictionaryStorages)
16
    {
17
        $this->dictionaryStorages = $dictionaryStorages;
18
    }
19
20
    /**
21
     * @return array<string, string>
22
     */
23
    public function load(): array
24
    {
25
        $dictionaries = [];
26
        foreach ($this->dictionaryStorages as $lang => $storages) {
27
            foreach ($storages as $storage) {
28
                $dictionaries[$lang] = array_merge($dictionaries[$lang] ?? [], $storage->load());
29
            }
30
        }
31
        return $dictionaries;
32
    }
33
}
34