AutoTranslateServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 2
A register() 0 16 1
1
<?php
2
3
namespace Ben182\AutoTranslate;
4
5
use Themsaid\Langman\Manager;
6
use Illuminate\Support\ServiceProvider;
7
use Ben182\AutoTranslate\Commands\AllCommand;
8
use Ben182\AutoTranslate\Commands\MissingCommand;
9
use Ben182\AutoTranslate\Translators\TranslatorInterface;
10
11
class AutoTranslateServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16 24
    public function boot()
17
    {
18 24
        if ($this->app->runningInConsole()) {
19 24
            $this->publishes([
20 24
                __DIR__.'/../config/config.php' => config_path('auto-translate.php'),
21 24
            ], 'config');
22
23
            // Registering package commands.
24 24
            $this->commands([
25 24
                AllCommand::class,
26
                MissingCommand::class,
27
            ]);
28
        }
29 24
    }
30
31
    /**
32
     * Register the application services.
33
     */
34 24
    public function register()
35
    {
36
        // Automatically apply the package configuration
37 24
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'auto-translate');
38
39 24
        $this->app->bind(TranslatorInterface::class, config('auto-translate.translator'));
40
41
        // Register the main class to use with the facade
42
        $this->app->singleton('auto-translate', function () {
43 24
            config([
44 24
                'langman.path' => config('auto-translate.path'),
45
            ]);
46
47 24
            return new AutoTranslate(app(Manager::class), app(TranslatorInterface::class));
48 24
        });
49 24
    }
50
}
51