GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ModuleAdminController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getIndex() 0 4 1
A missingMethod() 0 4 1
1
<?php
2
3
namespace LaravelFlare\Flare\Admin\Modules;
4
5
use LaravelFlare\Flare\Admin\AdminManager;
6
use LaravelFlare\Flare\Http\Controllers\FlareController;
7
8
class ModuleAdminController extends FlareController
9
{
10
    /**
11
     * Admin Instance.
12
     * 
13
     * @var 
14
     */
15
    protected $admin;
16
17
    /**
18
     * __construct.
19
     * 
20
     * @param AdminManager $adminManager
21
     */
22
    public function __construct(AdminManager $adminManager)
23
    {
24
        // Must call parent __construct otherwise 
25
        // we need to redeclare checkpermissions
26
        // middleware for authentication check
27
        parent::__construct($adminManager);
28
29
        $this->admin = $this->adminManager->getAdminInstance();
30
31
        view()->share('moduleAdmin', $this->admin);
0 ignored issues
show
Bug introduced by
The method share does only exist in Illuminate\Contracts\View\Factory, but not in Illuminate\View\View.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
32
    }
33
34
    /**
35
     * Index page for Module.
36
     * 
37
     * @return \Illuminate\Http\Response
38
     */
39
    public function getIndex()
40
    {
41
        return view($this->admin->getView(), $this->admin->getViewData());
42
    }
43
44
    /**
45
     * Method is called when the appropriate controller
46
     * method is unable to be found or called.
47
     * 
48
     * @param array $parameters
49
     * 
50
     * @return
51
     */
52
    public function missingMethod($parameters = array())
53
    {
54
        return parent::missingMethod();
55
    }
56
}
57