Completed
Push — master ( d944f0...12d1a2 )
by Jorijn
01:57
created

ServiceProvider::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 22
ccs 0
cts 16
cp 0
rs 9.2
cc 2
eloc 14
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Jorijn\LaravelSecurityChecker;
4
5
use Jorijn\LaravelSecurityChecker\Console\SecurityCommand;
6
use Jorijn\LaravelSecurityChecker\Console\SecurityMailCommand;
7
8
class ServiceProvider extends \Illuminate\Support\ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Register the service provider.
19
     *
20
     * @return void
21
     */
22
    public function register()
23
    {
24
        $configPath = __DIR__.'/../config/laravel-security-checker.php';
25
        $this->mergeConfigFrom($configPath, 'laravel-security-checker');
26
    }
27
28
    /**
29
     * Bootstrap the application events.
30
     *
31
     * @return void
32
     */
33
    public function boot()
34
    {
35
        // configuration
36
        $configPath = __DIR__.'/../config/laravel-security-checker.php';
37
        $this->publishes([ $configPath => $this->getConfigPath() ], 'config');
38
39
        // views
40
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-security-checker');
41
        $this->publishes([
42
            __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-security-checker'),
43
        ], 'views');
44
45
        // translations
46
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-security-checker');
47
        $this->publishes([
48
            __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-security-checker'),
49
        ], 'translations');
50
51
        if ($this->app->runningInConsole()) {
52
            $this->commands([
53
                SecurityCommand::class,
54
                SecurityMailCommand::class,
55
            ]);
56
        }
57
    }
58
59
    /**
60
     * Get the config path
61
     *
62
     * @return string
63
     */
64
    protected function getConfigPath()
65
    {
66
        return config_path('laravel-security-checker.php');
67
    }
68
69
    /**
70
     * Publish the config file
71
     *
72
     * @param  string $configPath
73
     */
74
    protected function publishConfig($configPath)
75
    {
76
        $this->publishes([ $configPath => config_path('laravel-security-checker.php') ], 'config');
77
    }
78
}
79