Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

MenuCRUDServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A setupRoutes() 0 12 2
A register() 0 4 1
1
<?php
2
3
namespace Backpack\MenuCRUD;
4
5
use Illuminate\Routing\Router;
6
use Illuminate\Support\ServiceProvider;
7
8
class MenuCRUDServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Where the route file lives, both inside the package and in the app (if overwritten).
19
     *
20
     * @var string
21
     */
22
    public $routeFilePath = '/routes/backpack/menucrud.php';
23
24
    /**
25
     * Perform post-registration booting of services.
26
     *
27
     * @return void
28
     */
29
    public function boot()
30
    {
31
        // publish migrations
32
        $this->publishes([__DIR__.'/database/migrations' => database_path('migrations')], 'migrations');
33
    }
34
35
    /**
36
     * Define the routes for the application.
37
     *
38
     * @param  \Illuminate\Routing\Router  $router
39
     * @return void
40
     */
41
    public function setupRoutes(Router $router)
0 ignored issues
show
Unused Code introduced by
The parameter $router is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        // by default, use the routes file provided in vendor
44
        $routeFilePathInUse = __DIR__.$this->routeFilePath;
45
46
        // but if there's a file with the same name in routes/backpack, use that one
47
        if (file_exists(base_path().$this->routeFilePath)) {
48
            $routeFilePathInUse = base_path().$this->routeFilePath;
49
        }
50
51
        $this->loadRoutesFrom($routeFilePathInUse);
52
    }
53
54
    /**
55
     * Register any package services.
56
     *
57
     * @return void
58
     */
59
    public function register()
60
    {
61
        $this->setupRoutes($this->app->router);
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...
62
    }
63
}
64