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 ( 5802ed...900bc8 )
by Hong
02:38
created

HandlerAbstract::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Logger
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Logger\Handler;
16
17
use Phossa2\Logger\LogLevel;
18
use Phossa2\Shared\Base\ObjectAbstract;
19
use Phossa2\Logger\Entry\LogEntryInterface;
20
use Phossa2\Logger\Formatter\FormatterInterface;
21
use Phossa2\Logger\Formatter\FormatterAwareTrait;
22
use Phossa2\Logger\Formatter\FormatterAwareInterface;
23
24
/**
25
 * HandlerAbstract
26
 *
27
 * @package Phossa2\Logger
28
 * @author  Hong Zhang <[email protected]>
29
 * @see     ObjectAbstract
30
 * @see     HandlerInterface
31
 * @version 2.0.0
32
 * @since   2.0.0 added
33
 */
34
abstract class HandlerAbstract extends ObjectAbstract implements HandlerInterface, FormatterAwareInterface
35
{
36
    use FormatterAwareTrait;
37
38
    /**
39
     * @var    string
40
     * @access protected
41
     */
42
    protected $level;
43
44
    /**
45
     * Stop log propagation
46
     *
47
     * @var    bool
48
     * @access protected
49
     */
50
    protected $stop;
51
52
    /**
53
     * Created with level handling
54
     *
55
     * @param  string $logLevel
0 ignored issues
show
Bug introduced by
There is no parameter named $logLevel. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
56
     * @param  FormatterInterface $formatter
57
     * @param  bool $stopPropagation
58
     * @access protected
59
     */
60
    public function __construct(
61
        /*# string */ $level = LogLevel::WARNING,
62
        FormatterInterface $formatter = null,
63
        /*# bool */ $stopPropagation = false
64
    ) {
65
        $this->level = $level;
66
        $this->stop  = (bool) $stopPropagation;
67
        $this->setFormatter($formatter);
0 ignored issues
show
Bug introduced by
It seems like $formatter defined by parameter $formatter on line 62 can be null; however, Phossa2\Logger\Formatter...reTrait::setFormatter() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function __invoke(LogEntryInterface $logEntry)
74
    {
75
        if ($this->isHandling($logEntry->getLevel())) {
76
            // format message
77
            ($this->getFormatter())($logEntry);
78
79
            // write method
80
            $this->write($logEntry);
81
82
            // stop propagation
83
            if ($this->stop) {
84
                $logEntry->stopPropagation(true);
85
            }
86
        }
87
    }
88
89
    /**
90
     * Destructor
91
     *
92
     * @access public
93
     */
94
    public function __destruct()
95
    {
96
        $this->close();
97
    }
98
99
    /**
100
     * Is this handler handling this level of message ?
101
     *
102
     * @param  string $level
103
     * @return bool
104
     * @access protected
105
     */
106
    protected function isHandling(/*# string */ $level)/*# : bool */
107
    {
108
        if (LogLevel::$levels[$level] >= LogLevel::$levels[$this->level]) {
109
            return true;
110
        } else {
111
            return false;
112
        }
113
    }
114
115
    /**
116
     * Write to the device
117
     *
118
     * @param  LogEntryInterface $logEntry
119
     * @access protected
120
     */
121
    abstract protected function write(LogEntryInterface $logEntry);
122
123
    /**
124
     * Close the handler, to be extended by siblings
125
     *
126
     * @access protected
127
     */
128
    protected function close()
129
    {
130
    }
131
}
132