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.

ConsoleOutputTable   A
last analyzed

Complexity

Total Complexity 23

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 23
lcom 1
cbo 3
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
C getCellFromPlaceholder() 0 23 17
A getRowFromColumns() 0 15 3
A getHeadFromColumns() 0 4 1
A write() 0 12 2
1
<?php
2
3
namespace Selim;
4
5
use Console_Table;
6
7
class ConsoleOutputTable extends Output implements IOutput
8
{
9
    private static function getCellFromPlaceholder($placeholder, SilverstripePage $sspage = null)
10
    {
11
        switch ($placeholder) {
12
            case '%s':
13
                return $sspage ? $sspage->getName() : "Site";
14
            case '%v':
15
                return $sspage ? $sspage->getVersion() : "Version";
16
            case '%da':
17
                return $sspage ? self::DefaultAdminText($sspage) : "DefaultAdmin";
18
            case '%el':
19
                return $sspage ? self::EmailLoggingText($sspage) : "EmailLogging";
20
            case '%et':
21
                return $sspage ? $sspage->getEnvironmentType() : "EnvironmentType";
22
            case '%m':
23
                return $sspage ? self::ModuleText($sspage) : "Modules";
24
            case '%cfgp':
25
                return $sspage ? $sspage->getConfigPhpPath() : "_config.php";
26
            case '%cfgy':
27
                return $sspage ? $sspage->getConfigYmlPath() : "_config/config.yml";
28
            default:
29
                return "";
30
        }
31
    }
32
33
    private static function getRowFromColumns($columns, SilverstripePage $sspage = null)
34
    {
35
        $matches = array();
36
        preg_match_all("/(?<pl>%s|%v|%da|%el|%et|%m|%cfgp|%cfgy)/", $columns, $matches);
37
        $row = array();
38
39
        foreach ($matches["pl"] as $m) {
40
            $c = self::getCellFromPlaceholder($m, $sspage);
41
            if ($c) {
42
                array_push($row, $c);
43
            }
44
        }
45
46
        return $row;
47
    }
48
49
    private static function getHeadFromColumns($columns)
50
    {
51
        return self::getRowFromColumns($columns);
52
    }
53
54
    public function write($columns = "%s%v%da%el%et%m")
55
    {
56
        $table = new Console_Table();
57
58
        $table->setHeaders(self::getHeadFromColumns($columns));
59
60
        foreach ($this->pages as $p) {
61
            $table->addRow(self::getRowFromColumns($columns, $p));
62
        }
63
64
        echo $table->getTable();
65
    }
66
}
67