Passed
Push — master ( 640218...c857fb )
by Ivan
01:50
created

StageFrontServiceProvider::loadMiddleware()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 5
cp 0.6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.2559
1
<?php
2
3
namespace CodeZero\StageFront;
4
5
use CodeZero\StageFront\Composers\ThrottleTimeRemaining;
6
use Illuminate\Support\ServiceProvider;
7
8
class StageFrontServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * The package name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'stagefront';
16
17
    /**
18
     * Bootstrap any application services.
19
     *
20
     * @return void
21
     */
22 13
    public function boot()
23
    {
24 13
        $this->loadRoutes();
25 13
        $this->loadViews();
26 13
        $this->loadViewComposers();
27 13
        $this->loadTranslations();
28 13
        $this->registerPublishableFiles();
29 13
    }
30
31
    /**
32
     * Register any application services.
33
     *
34
     * @return void
35
     */
36 13
    public function register()
37
    {
38 13
        $this->mergeConfig();
39 13
    }
40
41
    /**
42
     * Load package routes.
43
     *
44
     * @return void
45
     */
46 13
    protected function loadRoutes()
47
    {
48 13
        $this->loadRoutesFrom(__DIR__.'/../routes/routes.php');
49 13
    }
50
51
    /**
52
     * Load package views.
53
     *
54
     * @return void
55
     */
56 13
    protected function loadViews()
57
    {
58 13
        $this->loadViewsFrom(__DIR__.'/../resources/views', $this->name);
59 13
    }
60
61
    /**
62
     * Load the package view composers.
63
     *
64
     * @return void
65
     */
66 13
    protected function loadViewComposers()
67
    {
68 13
        view()->composer('stagefront::429', ThrottleTimeRemaining::class);
69 13
    }
70
71
    /**
72
     * Load package translations.
73
     *
74
     * @return void
75
     */
76 13
    protected function loadTranslations()
77
    {
78 13
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', $this->name);
79 13
    }
80
81
    /**
82
     * Register the publishable files.
83
     *
84
     * @return void
85
     */
86 13
    protected function registerPublishableFiles()
87
    {
88 13
        $this->publishes([
89 13
            __DIR__."/../config/{$this->name}.php" => config_path("{$this->name}.php"),
90 13
        ], 'config');
91
92 13
        $this->publishes([
93 13
            __DIR__."/../resources/views" =>  resource_path("views/vendor/{$this->name}"),
94 13
        ], 'views');
95
96 13
        $this->publishes([
97 13
            __DIR__."/../resources/lang" =>  resource_path("lang/vendor/{$this->name}"),
98 13
        ], 'lang');
99 13
    }
100
101
    /**
102
     * Merge published configuration file with
103
     * the original package configuration file.
104
     *
105
     * @return void
106
     */
107 13
    protected function mergeConfig()
108
    {
109 13
        $this->mergeConfigFrom(__DIR__."/../config/{$this->name}.php", $this->name);
110 13
    }
111
}
112