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

Completed
Push — master ( 7fd57f...ddf3cc )
by Mark
02:55
created

Global.php ➔ getMorphedModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
    /**
4
     * Return the auth account instance class.
5
     *
6
     * @return \App\Model\Account|\Illuminate\Contracts\Auth\Authenticatable
7
     */
8
    function account()
9
    {
10
        return auth()->user();
0 ignored issues
show
Bug introduced by
The method user does only exist in Illuminate\Contracts\Auth\Guard, but not in Illuminate\Contracts\Auth\Factory.

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...
11
    }
12
13
    /**
14
     * Return the webshelf framework version.
15
     *
16
     * @return App\Framework
17
     */
18
    function framework()
19
    {
20
        return app(App\Framework::class);
21
    }
22
23
    /**
24
     * @return \App\Classes\SettingsManager
25
     */
26
    function settings()
27
    {
28
        return app(\App\Classes\SettingsManager::class);
29
    }
30
31
    /**
32
     * @return \App\Classes\PluginManager
33
     */
34
    function plugins()
35
    {
36
        return app(\App\Classes\PluginManager::class);
37
    }
38
39
    /**
40
     * @return \App\Classes\Library\StyleCSS\Style
41
     */
42
    function css()
43
    {
44
        return app(\App\Classes\Library\StyleCSS\Style::class);
45
    }
46
47
    /**
48
     * @param string $table
49
     * @param int $id
50
     * @return App\Classes\Interfaces\Linkable
51
     */
52
    function getMorphedModel(string $table, int $id)
53
    {
54
        return app($table)->whereKey($id)->first();
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    function currentURI()
61
    {
62
        $route = basename(request()->path()) ?: 'index';
63
64
        return $route != '' ? $route : 'index';
65
    }
66
67
    /**
68
     * Return an array of the segmented url path.
69
     *
70
     * @return array
71
     */
72
    function segmentRequestPath()
73
    {
74
        $path = app('request')->path();
75
76
        if ($path == '/') {
77
            return ['index'];
78
        }
79
80
        return explode('/', $path);
81
    }
82
83
    /**
84
     * Turn a boolean value into readable data.
85
     * true  = Active
86
     * false = Inactive.
87
     *
88
     * @param $boolean
89
     * @param null $trueMessage
90
     * @param null $falseMessage
91
     * @return string
92
     * @internal param null $true
93
     * @internal param null $false
94
     * @deprecated
95
     */
96
    function bool2Status($boolean, $trueMessage = null, $falseMessage = null)
97
    {
98
        if ($boolean == true) {
99
            return '<span class="status green">'.($trueMessage ?: 'Active').'</span>';
100
        } else {
101
            return '<span class="status red">'.($falseMessage ?: 'Inactive').'</span>';
102
        }
103
    }
104