Completed
Push — master ( 3e605b...8e8897 )
by Nassif
07:14
created

Puller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 41
ccs 19
cts 19
cp 1
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 1
    public function __construct(TranslationsSheet $translationsSheet, Writer $writer)
20
    {
21 1
        $this->translationsSheet = $translationsSheet;
22 1
        $this->writer = $writer;
23
24 1
        $this->nullOutput();
25 1
    }
26
27 1
    public function pull()
28
    {
29 1
        $this->output->writeln('<comment>Pulling translation from Spreadsheet</comment>');
30 1
        $translations = $this->getTranslations();
31
32 1
        $this->output->writeln('<comment>Writing languages files :</comment>');
33 1
        $this->writer
34 1
            ->withOutput($this->output)
35 1
            ->setTranslations($translations)
36 1
            ->write();
37
38 1
        $this->output->writeln('<info>Done.</info>');
39 1
    }
40
41 1
    public function getTranslations()
42
    {
43 1
        $header = $this->translationsSheet->getSpreadsheet()->getCamelizedHeader();
44
45 1
        $translations = $this->translationsSheet->readTranslations();
46
47 1
        return Util::keyValues($translations, $header);
48
    }
49
}
50