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

Pusher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 7
dl 0
loc 49
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A push() 0 19 1
A getScannedAndTransformedTranslations() 0 6 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\Reader;
8
use Nikaia\TranslationSheet\Translation\Transformer;
9
10
class Pusher
11
{
12
    use Output;
13
14
    /** @var Reader */
15
    protected $reader;
16
17
    /** @var TranslationsSheet */
18
    protected $translationsSheet;
19
20
    /** @var Transformer */
21
    protected $transformer;
22
23 1
    public function __construct(Reader $reader, TranslationsSheet $translationsSheet, Transformer $transformer)
24
    {
25 1
        $this->reader = $reader;
26 1
        $this->translationsSheet = $translationsSheet;
27 1
        $this->transformer = $transformer;
28
29 1
        $this->nullOutput();
30 1
    }
31
32 1
    public function push()
33
    {
34 1
        $this->output->writeln('<comment>Scanning languages files</comment>');
35 1
        $translations = $this->getScannedAndTransformedTranslations();
36
37 1
        $this->output->writeln('<comment>Preparing spreasheet for new write operation</comment>');
38 1
        $this->translationsSheet->prepareForWrite();
39
40 1
        $this->output->writeln('<comment>Updating header</comment>');
41 1
        $this->translationsSheet->updateHeaderRow();
42
43 1
        $this->output->writeln('<comment>Writing translations in the spreadsheet</comment>');
44 1
        $this->translationsSheet->writeTranslations($translations->toArray());
45
46 1
        $this->output->writeln('<comment>Styling document</comment>');
47 1
        $this->translationsSheet->styleDocument();
48
49 1
        $this->output->writeln('<info>Done</info>.');
50 1
    }
51
52 1
    public function getScannedAndTransformedTranslations()
53
    {
54 1
        return $this->transformer
55 1
            ->setLocales($this->translationsSheet->getSpreadsheet()->getLocales())
56 1
            ->transform($this->reader->scan());
57
    }
58
}
59