Completed
Branch master (e25020)
by Richan
03:06
created

ServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A register() 0 8 1
1
<?php
2
3
namespace RichanFongdasen\I18n;
4
5
use Illuminate\Support\ServiceProvider as Provider;
6
7
class ServiceProvider extends Provider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        $this->publishes([
17
            realpath(__DIR__.'/../config/i18n.php') => config_path('i18n.php'),
18
        ], 'config');
19
20
        $this->publishes([
21
            realpath(__DIR__.'/../database/migrations/') => database_path('migrations'),
22
        ], 'migrations');
23
24
        $this->publishes([
25
            realpath(__DIR__.'/../storage/i18n/') => storage_path('i18n'),
26
        ], 'languages.json');
27
    }
28
29
    /**
30
     * Register the application services.
31
     *
32
     * @return void
33
     */
34
    public function register()
35
    {
36
        $this->mergeConfigFrom(realpath(__DIR__.'/../config/i18n.php'), 'i18n');
37
38
        $this->app->singleton(I18nService::class, function () {
39
            return new I18nService(request());
40
        });
41
    }
42
}
43