Completed
Push — master ( 89313f...8b5ee1 )
by Nassif
02:33
created

Prepare::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Nikaia\TranslationSheet\Commands;
4
5
use Illuminate\Console\Command;
6
use Nikaia\TranslationSheet\Pusher;
7
use Nikaia\TranslationSheet\Spreadsheet;
8
use Nikaia\TranslationSheet\Translation\Writer;
9
use Nikaia\TranslationSheet\Util;
10
11
class Prepare extends Command
12
{
13
    protected $signature = 'translation_sheet:prepare';
14
15
    protected $description = 'Rewrite locales languages files by removing comments and sorting keys. This most likely reduce and simplify conflicts when pulling translations from spreadsheet.';
16
17 1
    public function handle(Pusher $pusher, Spreadsheet $spreadsheet, Writer $writer)
18
    {
19 1
        $this->output->writeln('<comment>Scanning local languages files</comment>');
20 1
        $translations = Util::keyValues(
21 1
            $pusher->getScannedAndTransformedTranslations(),
22 1
            $spreadsheet->getCamelizedHeader()
23
        );
24
25 1
        $this->output->writeln('<comment>Rewriting :</comment>');
26 1
        $writer->withOutput($this->output)->setTranslations($translations)->write();
27
28 1
        $this->output->writeln('<info>Done.</info>');
29 1
    }
30
}
31