Setup::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 2
cts 2
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Nikaia\TranslationSheet\Commands;
4
5
use Illuminate\Console\Command;
6
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
7
use Nikaia\TranslationSheet\Spreadsheet;
8
9
class Setup extends Command
10
{
11
    protected $signature = 'translation_sheet:setup';
12
13 1
    protected $description = 'Setup spreadsheet and get it ready to host translations';
14
15 1
    public function handle(Spreadsheet $spreadsheet)
16 1
    {
17
        $spreadsheet->ensureConfiguredSheetsAreCreated();
18
19
        $spreadsheet->sheets()->each(function (TranslationsSheet $translationsSheet) {
20
            $this->output->writeln(
21
                '<comment>Setting up translations sheet [' . $translationsSheet->getTitle() . ']</comment>'
22
            );
23
24
            $translationsSheet->api()->addBatchRequests(
25
                $translationsSheet->api()->setTabColor($translationsSheet->getId(), $translationsSheet->getTabColor())
26
            );
27
        });
28
29
        $spreadsheet->api()->sendBatchRequests();
30
31
        $this->output->writeln('<info>Done. Spreasheet is ready.</info>');
32
    }
33
}
34