ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

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