Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Lines | 20 |
Ratio | 100 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
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 | |||
39 |
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.