Completed
Push — master ( bcac64...9b6ee4 )
by Nassif
11:39
created

Puller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 41
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A pull() 0 13 1
A getTranslations() 0 8 1
1
<?php
2
3
namespace Nikaia\TranslationSheet;
4
5
use Nikaia\TranslationSheet\Commands\Output;
6
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
7
use Nikaia\TranslationSheet\Translation\Writer;
8
9
class Puller
10
{
11
    use Output;
12
13
    /** @var TranslationsSheet */
14
    protected $translationsSheet;
15
16
    /** @var Writer */
17
    protected $writer;
18
19
    public function __construct(TranslationsSheet $translationsSheet, Writer $writer)
20
    {
21
        $this->translationsSheet = $translationsSheet;
22
        $this->writer = $writer;
23
24
        $this->nullOutput();
25
    }
26
27
    public function pull()
28
    {
29
        $this->output->writeln('<comment>Pulling translation from Spreadsheet</comment>');
30
        $translations = $this->getTranslations();
31
32
        $this->output->writeln('<comment>Writing languages files :</comment>');
33
        $this->writer
34
            ->withOutput($this->output)
35
            ->setTranslations($translations)
36
            ->write();
37
38
        $this->output->writeln('<info>Done.</info>');
39
    }
40
41
    public function getTranslations()
42
    {
43
        $header = $this->translationsSheet->getSpreadsheet()->getCamelizedHeader();
44
45
        $translations = $this->translationsSheet->readTranslations();
46
47
        return Util::keyValues($translations, $header);
48
    }
49
}
50