InlineTranslationServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 15 2
A register() 0 6 1
A registerMiddleware() 0 5 1
A addRoute() 0 4 1
1
<?php
2
3
namespace BeyondCode\InlineTranslation;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
8
class InlineTranslationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__.'/../config/config.php' => config_path('inline-translation.php'),
18
            ], 'config');
19
        }
20
21
        $this->loadTranslationsFrom(__DIR__.'/translations', 'laravel-inline-translation');
22
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'inline-translation');
23
24
        $this->registerMiddleware(InlineTranslationMiddleware::class);
25
26
        $this->addRoute();
27
    }
28
29
    /**
30
     * Register the application services.
31
     */
32
    public function register()
33
    {
34
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'inline-translation');
35
36
        $this->app->singleton(InlineTranslation::class);
37
    }
38
39
40
    /**
41
     * Register the middleware
42
     *
43
     * @param  string $middleware
44
     */
45
    protected function registerMiddleware($middleware)
46
    {
47
        $kernel = $this->app[Kernel::class];
48
        $kernel->pushMiddleware($middleware);
49
    }
50
51
    protected function addRoute()
52
    {
53
        app('router')->post('/_beyondcode/translation', InlineTranslationController::class.'@store');
54
    }
55
}
56