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 ( cadef0...55fd4a )
by James
02:47
created

After   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 66
ccs 26
cts 26
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteBlankLines() 0 12 3
A continuingDirectives() 0 13 3
A setLineIfPrevious() 0 15 3
1
<?php
2
3
/**
4
 * This file is part of WebHelper Parser.
5
 *
6
 * (c) James <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WebHelper\Parser\Parser;
13
14
/**
15
 * Methods that can be applied depending of the kind of server after a parsed configuration file turns into an array.
16
 *
17
 * @author James <[email protected]>
18
 */
19
class After
20
{
21
    /**
22
     * Trim all blank lines.
23
     *
24
     * @param array $activeConfig config file exploded in an array of lines
25
     *
26
     * @return array an array cleaned of blank lines
27
     */
28 11
    public static function deleteBlankLines(array $activeConfig = array())
29
    {
30 11
        $cleanedActiveConfig = [];
31
32 11
        foreach (array_map('trim', $activeConfig) as $line) {
33 11
            if ($line != '') {
34 9
                $cleanedActiveConfig[] = $line;
35 9
            }
36 11
        }
37
38 11
        return $cleanedActiveConfig;
39
    }
40
41
    /**
42
     * Reassembles discontinued simple directives in one line.
43
     *
44
     * In an Apache server context, it may be encountered.
45
     *
46
     * @param array $activeConfig config file exploded in an array of lines
47
     *
48
     * @return array an array with continuing lines gathered as one
49
     */
50 5
    public static function continuingDirectives(array $activeConfig = array())
51
    {
52 5
        $cleanedActiveConfig = [];
53
54
        //Continuing directives with "\" at the very end of a line are reassembled
55 5
        foreach ($activeConfig as $line) {
56 5
            if (!static::setLineIfPrevious($line)) {
0 ignored issues
show
Bug introduced by
Since setLineIfPrevious() 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 setLineIfPrevious() 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...
57 5
                $cleanedActiveConfig[] = $line;
58 5
            }
59 5
        }
60
61 5
        return $cleanedActiveConfig;
62
    }
63
64
    /**
65
     * Helps to gather continuing lines as one.
66
     *
67
     * @param string &$line a line to add to previous lines or matching a contuining end line marker
68
     */
69 5
    private static function setLineIfPrevious(&$line)
70
    {
71 5
        static $previousLine = '';
72
73 5
        if ($previousLine) {
74 1
            $line = $previousLine.' '.trim($line);
75 1
            $previousLine = '';
76 1
        }
77
78 5
        if (preg_match('/(.+)\\\$/', $line, $container)) {
79 1
            $previousLine = $container[1];
80 1
        }
81
82 5
        return $previousLine;
83
    }
84
}
85