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.
Completed
Pull Request — master (#172)
by
unknown
02:11
created

Link   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A allCached() 0 8 3
A returnUrls() 0 9 3
A getMainUrls() 0 9 3
A getAndSave() 0 5 1
1
<?php
2
namespace Serverfireteam\Panel;
3
4
use Illuminate\Database\Eloquent\Model;
5
6
class Link extends Model {
7
8
    protected $table = 'links';
9
10
    static $cache = [];
11
12
    public static function allCached($forceRefresh = false)
13
    {
14
        if(!isset(static::$cache['all']) || $forceRefresh) {
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
15
            static::$cache['all'] = Link::all();
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
16
        }
17
18
        return static::$cache['all'];
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
19
    }
20
21
    public static function returnUrls($forceRefresh = false) {
22
23
        if(!isset(static::$cache['all_urls']) || $forceRefresh) {
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
24
            $configs = Link::allCached($forceRefresh);
25
            static::$cache['all_urls'] =  $configs->pluck('url')->toArray();
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
26
        }
27
28
        return static::$cache['all_urls'];
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
29
    }
30
31
    public static function getMainUrls($forceRefresh = false){
32
33
        if(!isset(static::$cache['main_urls']) || $forceRefresh) {
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
34
            $configs = Link::where('main', '=', true)->get(['url']);
35
            static::$cache['main_urls'] = $configs->pluck('url')->toArray();
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
36
        }
37
38
        return static::$cache['main_urls'];
0 ignored issues
show
Bug introduced by
Since $cache is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $cache to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
39
    }
40
41
42
    public function getAndSave($url, $display){
43
        $this->url = $url;
44
        $this->display = $display;
45
        $this->save();
46
    }
47
48
49
    protected $fillable = array('url', 'display');
50
51
}
52