LaravelWebArtisanServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 69
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRouter() 0 3 1
A register() 0 3 1
A registerMiddleware() 0 4 1
A boot() 0 31 1
1
<?php
2
3
namespace Micheledamo\LaravelWebArtisan;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Routing\Router;
8
use Micheledamo\LaravelWebArtisan\Middleware\WebArtisanEnabled;
9
10
class LaravelWebArtisanServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Perform post-registration booting of services.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        $this->publishes([
20
            __DIR__.'/../config/config.php' => config_path('webartisan.php'),
21
        ], 'config');
22
23
        $routeConfig = [
24
            'namespace' => 'Micheledamo\LaravelWebArtisan\Controllers',
25
            'prefix' => $this->app['config']->get('webartisan.route_prefix'),
26
            'domain' => $this->app['config']->get('webartisan.route_domain'),
27
            'middleware' => 'web'
28
        ];
29
30
        $this->getRouter()->group($routeConfig, function($router) {
31
            $router->post('run', [
32
                'uses' => 'WebArtisanCommandController@run',
0 ignored issues
show
Bug introduced by
The controller App\Http\Controllers\WebArtisanCommandController does not seem to exist.

If there is a route defined but the controller class cannot be found there are two options: 1. the controller class needs to be implemented or 2. the route is outdated and can be removed.

If ?FooController? was found and ?BarController? is missing for the following example, either the controller should be implemented or the route should be removed:

$app->group(['as' => 'foo', 'prefix' => 'foo', 'namespace' => 'Foo'], function($app) {
    $app->group(['as' => 'foo', 'prefix' => 'foo'], function($app) {
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'FooController@getFoo']);
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'BarController@getBar']);
    });
});
Loading history...
33
                'as' => 'webartisan.run',
34
            ]);
35
            $router->post('auth', [
36
                'uses' => 'WebArtisanAuthController@auth',
0 ignored issues
show
Bug introduced by
The controller App\Http\Controllers\WebArtisanAuthController does not seem to exist.

If there is a route defined but the controller class cannot be found there are two options: 1. the controller class needs to be implemented or 2. the route is outdated and can be removed.

If ?FooController? was found and ?BarController? is missing for the following example, either the controller should be implemented or the route should be removed:

$app->group(['as' => 'foo', 'prefix' => 'foo', 'namespace' => 'Foo'], function($app) {
    $app->group(['as' => 'foo', 'prefix' => 'foo'], function($app) {
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'FooController@getFoo']);
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'BarController@getBar']);
    });
});
Loading history...
37
                'as' => 'webartisan.auth',
38
            ]);
39
            $router->post('logout', [
40
                'uses' => 'WebArtisanAuthController@logout',
0 ignored issues
show
Bug introduced by
The controller App\Http\Controllers\WebArtisanAuthController does not seem to exist.

If there is a route defined but the controller class cannot be found there are two options: 1. the controller class needs to be implemented or 2. the route is outdated and can be removed.

If ?FooController? was found and ?BarController? is missing for the following example, either the controller should be implemented or the route should be removed:

$app->group(['as' => 'foo', 'prefix' => 'foo', 'namespace' => 'Foo'], function($app) {
    $app->group(['as' => 'foo', 'prefix' => 'foo'], function($app) {
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'FooController@getFoo']);
        $app->get('/all/{from}/{to}', ['as' => 'all', 'uses' => 'BarController@getBar']);
    });
});
Loading history...
41
                'as' => 'webartisan.logout',
42
            ]);
43
        });
44
45
        $this->loadViewsFrom(__DIR__.'/Resources/Views', 'webartisan');
46
47
        $this->registerMiddleware(WebArtisanEnabled::class);
48
    }
49
50
    /**
51
     * Register any package services.
52
     *
53
     * @return void
54
     */
55
    public function register()
56
    {
57
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'webartisan');
58
    }
59
60
    /**
61
     * Register the Web Artisan Middleware
62
     *
63
     * @param  string $middleware
64
     */
65
    protected function registerMiddleware($middleware)
66
    {
67
        $kernel = $this->app[Kernel::class];
68
        $kernel->pushMiddleware($middleware);
69
    }
70
71
    /**
72
     * Get the active router.
73
     *
74
     * @return Router
75
     */
76
    protected function getRouter()
77
    {
78
        return $this->app['router'];
79
    }
80
}