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
Push — master ( 1e49b0...82ab4e )
by Mewes
12:52
created

Filesystem::getDelegate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Helper;
4
5
use Symfony\Component\Filesystem\Exception\IOException;
6
use Symfony\Component\Filesystem\Filesystem as BaseFilesystem;
7
8
/**
9
 * Class Filesystem.
10
 */
11
class Filesystem
12
{
13
    /**
14
     * @var BaseFilesystem
15
     */
16
    private static $delegate;
17
18
    /**
19
     * Creates a directory recursively.
20
     *
21
     * @param string|array|\Traversable $dirs The directory path
22
     * @param int                       $mode The directory mode
23
     *
24
     * @throws IOException On any directory creation failure
25
     */
26 1
    public static function mkdir($dirs, int $mode = 0777)
27
    {
28 1
        static::getDelegate()->mkdir($dirs, $mode);
0 ignored issues
show
Bug introduced by
Since getDelegate() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of getDelegate() to at least protected.

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

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 {
      private static function getTemperature() {
        return "-182 °C";
    }
}

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

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
29 1
    }
30
31
    /**
32
     * Checks the existence of files or directories.
33
     *
34
     * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to check
35
     *
36
     * @return bool true if the file exists, false otherwise
37
     */
38 25
    public static function exists($files): bool
39
    {
40 25
        return static::getDelegate()->exists($files);
0 ignored issues
show
Bug introduced by
Since getDelegate() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of getDelegate() to at least protected.

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

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 {
      private static function getTemperature() {
        return "-182 °C";
    }
}

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

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
41
    }
42
43
    /**
44
     * Removes files or directories.
45
     *
46
     * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove
47
     *
48
     * @throws IOException When removal fails
49
     */
50
    public static function remove($files)
51
    {
52
        static::getDelegate()->remove($files);
0 ignored issues
show
Bug introduced by
Since getDelegate() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of getDelegate() to at least protected.

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

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 {
      private static function getTemperature() {
        return "-182 °C";
    }
}

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

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
53
    }
54
55
    /**
56
     * Atomically dumps content into a file.
57
     *
58
     * @param string $filename The file to be written to
59
     * @param string $content  The data to write into the file
60
     *
61
     * @throws IOException If the file cannot be written to
62
     */
63 100
    public static function dumpFile(string $filename, string $content)
64
    {
65 100
        static::getDelegate()->dumpFile($filename, $content);
0 ignored issues
show
Bug introduced by
Since getDelegate() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of getDelegate() to at least protected.

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

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 {
      private static function getTemperature() {
        return "-182 °C";
    }
}

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

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

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
66 100
    }
67
68
    /**
69
     * @return BaseFilesystem
70
     */
71 107
    private static function getDelegate(): BaseFilesystem
72
    {
73 107
        if (!static::$delegate) {
0 ignored issues
show
Bug introduced by
Since $delegate is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $delegate 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...
74
            static::$delegate = new BaseFilesystem();
0 ignored issues
show
Bug introduced by
Since $delegate is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $delegate 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...
75
        }
76
77 107
        return static::$delegate;
0 ignored issues
show
Bug introduced by
Since $delegate is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $delegate 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...
78
    }
79
}
80