PackageTranslatorLoaderServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 1
b 0
f 0
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 2
A register() 0 12 1
A bootForConsole() 0 8 1
A provides() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SolumDeSignum\PackageTranslatorLoader;
6
7
use Illuminate\Support\ServiceProvider;
8
9
class PackageTranslatorLoaderServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Perform post-registration booting of services.
13
     *
14
     * @return void
15
     */
16
    public function boot(): void
17
    {
18
        // Publishing is only necessary when using the CLI.
19
        if ($this->app->runningInConsole()) {
20
            $this->bootForConsole();
21
        }
22
    }
23
24
    /**
25
     * Register any package services.
26
     *
27
     * @return void
28
     */
29
    public function register(): void
30
    {
31
        $this->mergeConfigFrom(
32
            __DIR__.'/../config/package-translator-loader.php',
33
            'package-translator-loader'
34
        );
35
36
        // Register the service the package provides.
37
        $this->app->singleton(
38
            'package-translator-loader',
39
            function ($app) {
40
                return new PackageTranslatorLoader($app);
41
            }
42
        );
43
    }
44
45
    /**
46
     * Get the services provided by the provider.
47
     *
48
     * @return array
49
     */
50
    public function provides(): array
51
    {
52
        return ['package-translator-loader'];
53
    }
54
55
    /**
56
     * Console-specific booting.
57
     *
58
     * @return void
59
     */
60
    protected function bootForConsole(): void
61
    {
62
        // Publishing the configuration file.
63
        $this->publishes(
64
            [
65
                __DIR__.'/../config/package-translator-loader.php' => config_path('package-translator-loader.php'),
66
            ],
67
            'package-translator-loader'
68
        );
69
    }
70
}
71