Passed
Branch develop (ac3b98)
by Jorijn
02:01
created

ServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
dl 0
loc 69
ccs 24
cts 26
cp 0.9231
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 22 2
A getConfigPath() 0 3 1
A publishConfig() 0 3 1
A register() 0 4 1
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 6
    public function register()
23
    {
24 6
        $configPath = __DIR__.'/../config/laravel-security-checker.php';
25 6
        $this->mergeConfigFrom($configPath, 'laravel-security-checker');
26 6
    }
27
28
    /**
29
     * Bootstrap the application events.
30
     *
31
     * @return void
32
     */
33 6
    public function boot()
34
    {
35
        // configuration
36 6
        $configPath = __DIR__.'/../config/laravel-security-checker.php';
37 6
        $this->publishes([ $configPath => $this->getConfigPath() ], 'config');
38
39
        // views
40 6
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-security-checker');
41 6
        $this->publishes([
42 6
            __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-security-checker'),
43 6
        ], 'views');
44
45
        // translations
46 6
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-security-checker');
47 6
        $this->publishes([
48 6
            __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-security-checker'),
49 6
        ], 'translations');
50
51 6
        if ($this->app->runningInConsole()) {
52 6
            $this->commands([
53 6
                SecurityCommand::class,
54 2
                SecurityMailCommand::class,
55 2
            ]);
56 2
        }
57 6
    }
58
59
    /**
60
     * Get the config path
61
     *
62
     * @return string
63
     */
64 6
    protected function getConfigPath()
65
    {
66 6
        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