TranslationSheetServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 55
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 10 1
A registerGoogleApiClient() 0 9 1
A registerSpreadsheet() 0 9 1
A registerCommands() 0 14 1
1
<?php
2
3
namespace Nikaia\TranslationSheet;
4
5
use Illuminate\Support\ServiceProvider;
6
use Nikaia\TranslationSheet\Client\Client;
7
use Nikaia\TranslationSheet\Commands\Lock;
8
use Nikaia\TranslationSheet\Commands\Open;
9
use Nikaia\TranslationSheet\Commands\Prepare;
10
use Nikaia\TranslationSheet\Commands\Publish;
11
use Nikaia\TranslationSheet\Commands\Pull;
12
use Nikaia\TranslationSheet\Commands\Push;
13
use Nikaia\TranslationSheet\Commands\Setup;
14
use Nikaia\TranslationSheet\Commands\Status;
15
use Nikaia\TranslationSheet\Commands\Unlock;
16
17
class TranslationSheetServiceProvider extends ServiceProvider
18 38
{
19
    public function boot()
20 38
    {
21 38
        $this->publishes([
22 38
            __DIR__.'/../config/config.php' => config_path('translation_sheet.php'),
23 38
        ], 'config');
24
    }
25 38
26
    public function register()
27 38
    {
28
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'translation_sheet');
29 38
30
        $this->registerGoogleApiClient();
31 38
32
        $this->registerSpreadsheet();
33 38
34 38
        $this->registerCommands();
35
    }
36 38
37
    private function registerGoogleApiClient()
38
    {
39 20
        $this->app->singleton(Client::class, function () {
40 20
            return Client::create(
41 20
                $this->app['config']['translation_sheet.serviceAccountCredentialsFile'],
42
                $this->app['config']['translation_sheet.googleApplicationName']
43 38
            );
44 38
        });
45
    }
46 38
47
    private function registerSpreadsheet()
48
    {
49 3
        $this->app->singleton(Spreadsheet::class, function () {
50 3
            return new Spreadsheet(
51 3
                $this->app['config']['translation_sheet.spreadsheetId'],
52
                Util::asArray($this->app['config']['translation_sheet.locales'])
53 38
            );
54 38
        });
55
    }
56 38
57
    private function registerCommands()
58 38
    {
59 38
        $this->commands([
60
            Setup::class,
61
            Push::class,
62
            Pull::class,
63
            Prepare::class,
64
            Lock::class,
65
            Unlock::class,
66
            Status::class,
67
            Open::class,
68 38
            Publish::class,
69
        ]);
70
    }
71
}
72