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.

Version   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 52
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersion() 0 4 1
A HasNewVersion() 0 6 1
A messageHasNewVersion() 0 8 2
A equalVersion() 0 4 1
A existVersion() 0 4 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 9 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace Classes\Update;
3
4
use Classes\Update\Content\GitHub;
5
6
require_once 'Content/GitHub.php';
7
require_once 'ProtocolFileContent.php';
8
9
class Version
10
{
11
    private static $_currentVersion = "1.6.2";
12
13
    private static $lastVersion;
14
15
    /**
16
     * @return string
17
     */
18
    public static function getVersion ()
19
    {
20
        return static::$_currentVersion;
0 ignored issues
show
Bug introduced by
Since $_currentVersion is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $_currentVersion 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...
21
    }
22
23
    /**
24
     * @return bool
25
     */
26
    public static function HasNewVersion ()
27
    {
28
        self::$lastVersion = GitHub::getInstance ()->getLastVersion ();
29
30
        return self::$lastVersion > static::$_currentVersion;
0 ignored issues
show
Bug introduced by
Since $_currentVersion is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $_currentVersion 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...
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function messageHasNewVersion ()
37
    {
38
        if ( self::HasNewVersion () )
39
        {
40
            return "\033[0;31mThere is a new version " . self::$lastVersion
41
                   . " available\033[0m \n";
42
        }
43
    }
44
45
    /**
46
     * @param $version
47
     *
48
     * @return bool
49
     */
50
    public static function equalVersion ( $version )
51
    {
52
        return $version === self::getVersion ();
53
    }
54
55
    public static function existVersion ( $version )
56
    {
57
        return GitHub::getInstance ()->hasPharByVersion ( $version );
58
    }
59
60
}