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.

After   A
last analyzed

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