BlogServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 25 2
A register() 0 4 1
A viewHandle() 0 7 1
A migrationHandle() 0 7 1
1
<?php
2
3
namespace Bantenprov\VueBlog;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Foundation\AliasLoader;
7
use Collective\Html\HtmlServiceProvider;
8
9
class BlogServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        if(!$this->app->routesAreCached()){
0 ignored issues
show
Bug introduced by
The method routesAreCached() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
            $this->app->router->group(
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
20
                [
21
                    'namespace' => 'Bantenprov\VueBlog\Controllers',
22
                    'prefix' => config('package.routing.prefix'),
23
                    // 'middleware' => config('package.routing.middleware')
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
                ]
25
                , function ()
26
            {
27
                require_once 'routes.php';
28
            });
29
        }
30
31
        //$this->loadRoutesFrom(__DIR__.'/routes.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
        $this->loadMigrationsFrom(__DIR__.'/migrations');
33
        $this->loadViewsFrom(__DIR__.'/resources/views', 'view');
34
35
36
        $this->app->register(HtmlServiceProvider::class);
37
        AliasLoader::getInstance(['Form'=>'\Collective\Html\FormFacade']);
38
        $this->viewHandle();
39
        $this->migrationHandle();
40
    }
41
42
    /**
43
     * Register the application services.
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
        //
50
    }
51
52
    protected function viewHandle()
53
    {
54
        $packageViewsPath = __DIR__.'/resources/assets/js/components';
55
        $this->publishes([
56
            $packageViewsPath => resource_path('assets/js/components'),
57
        ], 'vue_assets');
58
    }
59
60
    protected function migrationHandle()
61
    {
62
        $packageMigrationsPath = __DIR__.'/migrations';
63
        $this->publishes([
64
            $packageMigrationsPath => database_path('migrations')
65
        ], 'vue_migrations');
66
    }
67
}
68