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 ( 64a210...2d6991 )
by Stan
02:42
created

Output   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
c 1
b 1
f 0
lcom 0
cbo 3
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B log() 0 33 6
1
<?php
2
3
/**
4
 * Exception output class
5
 *
6
 * @package Teebot (Telegram bot framework)
7
 *
8
 * @author Stanislav Drozdov <[email protected]>
9
 */
10
11
namespace Teebot\Exception;
12
13
use Teebot\Command\Executor;
14
15
class Output
16
{
17
    public static function log($e)
18
    {
19
        $logFile = Executor::getInstance()->getConfig()->getLogFile();
20
        $type    = "\\Exception";
21
        $pattern = "%s";
22
23
        if ($e instanceof AbstractException) {
24
            $type    = $e->getType();
25
            $pattern = $e->getColorMessagePattern();
26
        }
27
28
        if ($logFile && (!file_exists($logFile) || is_writable($logFile))) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $logFile of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
29
            $fh = fopen($logFile, "a");
30
31
            $logString = sprintf(
32
                "[%s] [%s] %s\n",
33
                date("H:i:s d.m.Y"),
34
                $type,
35
                $e->getMessage()
36
            );
37
            fwrite($fh, $logString);
38
            fclose($fh);
39
        } else {
40
            echo sprintf(
41
                $pattern,
42
                $e->getMessage()
43
            ). "\n";
44
        }
45
46
        if ($e instanceof Fatal) {
47
            exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method log() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
48
        }
49
    }
50
}