Pull   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 20 20 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Nikaia\TranslationSheet\Commands;
4
5
use Illuminate\Console\Command;
6
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
7
use Nikaia\TranslationSheet\SheetPuller;
8
use Nikaia\TranslationSheet\Spreadsheet;
9
10 View Code Duplication
class Pull extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    protected $signature = 'translation_sheet:pull';
13
14
    protected $description = 'Pull translations from spreadsheet and override local languages files';
15
16
    public function handle(SheetPuller $puller, Spreadsheet $spreadsheet)
17
    {
18
        try {
19
            $spreadsheet->sheets()->each(function (TranslationsSheet $translationsSheet) use ($puller) {
20
                $puller
21
                    ->setTranslationsSheet($translationsSheet)
22
                    ->withOutput($this->output)
23
                    ->pull();
24
25
                $translationsSheet->api()->reset();
26
            });
27
        } catch (\ErrorException $e) {
28
            if ($e->getMessage() === 'Trying to access array offset on value of type null') {
29
                $this->error('Something is wrong. Did you just add an extra sheet ? try to re-run translation_sheet:setup!');
30
                return;
31
            }
32
33
            throw $e;
34
        }
35
    }
36
37
38
}
39