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 — 3.0 ( 9f183d...48ce76 )
by Vermeulen
04:41
created

ErrorsDisplay::defaultCliErrorRender()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 8.8571
cc 2
eloc 17
nc 2
nop 6
1
<?php
2
3
namespace BFW\Core;
4
5
class ErrorsDisplay
6
{
7
    /**
8
     * The default cli render in BFW
9
     * 
10
     * @param string   $errType : Human readable error severity
11
     * @param string   $errMsg : Error/exception message
12
     * @param string   $errFile : File where the error/exception is triggered
13
     * @param integer  $errLine : Line where the error/exception is triggered
14
     * @param array    $backtrace : Error/exception backtrace
15
     * @param int|null $exceptionCode : (default null) Exception code
16
     * 
17
     * @return void
18
     */
19
    public static function defaultCliErrorRender(
20
        $errType,
21
        $errMsg,
22
        $errFile,
23
        $errLine,
24
        $backtrace,
0 ignored issues
show
Unused Code introduced by
The parameter $backtrace is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
        $exceptionCode
26
    ) {
27
        if (!empty($exceptionCode)) {
28
            $errMsg = '#'.$exceptionCode.' : '.$errMsg;
29
        }
30
        
31
        //Create the cli message
32
        $msgError = $errType.' Error : '.$errMsg.
33
            ' in '.$errFile.' at line '.$errLine;
34
        
35
        //Display the message with displayMsg function
36
        \BFW\Helpers\Cli::displayMsg(
37
            $msgError,
38
            'white',
39
            'red'
40
        );
41
        
42
        ob_flush();
43
        exit;
44
    }
45
46
    /**
47
     * The default error render in BFW
48
     * 
49
     * @param string   $errType : Human readable error severity
50
     * @param string   $errMsg : Error/exception message
51
     * @param string   $errFile : File where the error/exception is triggered
52
     * @param integer  $errLine : Line where the error/exception is triggered
53
     * @param array    $backtrace : Error/exception backtrace
54
     * @param int|null $exceptionCode : (default null) Exception code
55
     * 
56
     * @return void
57
     */
58
    public static function defaultErrorRender(
59
        $errType,
60
        $errMsg,
61
        $errFile,
62
        $errLine,
63
        $backtrace,
64
        $exceptionCode
65
    ) {
66
        http_response_code(500);
67
        ob_clean();
68
69
        if (!empty($exceptionCode)) {
70
            $errMsg = '#'.$exceptionCode.' : '.$errMsg;
71
        }
72
        
73
        echo '
74
        <!doctype html>
75
        <html lang="fr">
76
            <head>
77
                <title>An error is detected !</title>
78
                <style>
79
                    html {padding:0; margin:0; background-color:#e3e3e3; font-family:sans-serif; font-size: 1em; word-wrap:break-word;}
80
                    div {position:relative; margin:auto; width:950px; border: 1px solid #a6c9e2; top: 30px; margin-bottom:10px;}
81
                    p {padding:0; margin:0;}
82
                    p.title {font-size:1.2em; background-color:#D0DCE9; padding:10px;}
83
                    p.info {padding:5px; margin-top:10px; margin-bottom:10px;}
84
                    fieldset {border:none; background-color: white;}
85
                    pre {width:910px; line-height:1.5;}
86
                </style>
87
            </head>
88
            <body>
89
                <div>
90
                    <p class="title">Niarf, an error is detected !</p>
91
                    <p class="info">'.$errType.' Error : <strong>'.$errMsg.'</strong> in '.$errFile.' at line '.$errLine.'</p>
92
                    <fieldset><pre>';
93
                        foreach ($backtrace as $i => $info) {
94
                            echo '#'.$i.'  '.$info['function'];
95
96
                            if (isset($info['args']) && count($info['args']) > 0) {
97
                                echo '(';
98
99
                                foreach ($info['args'] as $iArgs => $args) {
100
                                    if ($iArgs > 0) {
101
                                        echo ', ';
102
                                    }
103
104
                                    if (is_array($args) || is_object($args)) {
105
                                        echo gettype($args);
106
                                    } elseif (is_null($args)) {
107
                                        echo 'null';
108
                                    } else {
109
                                        echo htmlentities($args);
110
                                    }
111
                                }
112
113
                                echo ')';
114
                            }
115
116
                            if (isset($info['file'], $info['line'])) {
117
                                echo ' called at ['.$info['file'].' line '.$info['line'].']';
118
                            }
119
                            echo "\n\n";
120
                        }
121
                    echo '</pre></fieldset>
122
                </div>
123
            <body>
124
        </html>
125
        ';
126
127
        ob_flush();
128
        exit;
129
    }
130
}
131