Prepare   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 9
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 25 1
1
<?php
2
3
namespace Nikaia\TranslationSheet\Commands;
4
5
use Illuminate\Console\Command;
6
use Nikaia\TranslationSheet\SheetPusher;
7
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
8
use Nikaia\TranslationSheet\Spreadsheet;
9
use Nikaia\TranslationSheet\Translation\Writer;
10
use Nikaia\TranslationSheet\Util;
11
12
class Prepare extends Command
13
{
14
    protected $signature = 'translation_sheet:prepare';
15
16
    protected $description = 'Rewrite locales languages files by removing comments and sorting keys. This most likely reduce and simplify conflicts when pulling translations from spreadsheet.';
17 1
18
    public function handle(SheetPusher $pusher, Spreadsheet $spreadsheet, Writer $writer)
19 1
    {
20 1
        $spreadsheet->sheets()->each(function (TranslationsSheet $translationsSheet) use ($pusher, $spreadsheet, $writer) {
21 1
22 1
            $this->output->writeln("<comment>Scanning local languages files for sheet [{$translationsSheet->getTitle()}]</comment>");
23
24
            $pusher = $pusher->setTranslationsSheet($translationsSheet);
0 ignored issues
show
Bug introduced by
Consider using a different name than the imported variable $pusher, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
25 1
26 1
            $translations = Util::keyValues(
27
                $pusher->getScannedAndTransformedTranslations(),
28 1
                $spreadsheet->getCamelizedHeader()
29 1
            );
30
31
            $this->output->writeln('<comment>.... Rewriting</comment>');
32
            $writer
33
                ->setTranslationsSheet($translationsSheet)
34
                ->setTranslations($translations)
35
                ->withOutput($this->output)
36
                ->write();
37
38
            $translationsSheet->api()->reset();
39
        });
40
41
        $this->output->writeln('<info>Done.</info>');
42
    }
43
}
44