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 ( 42143b...311ae6 )
by Cees-Jan
01:40
created

StdioLogger::withNewLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\PSR3\Stdio;
4
5
use Clue\React\Stdio\Stdio;
6
use Psr\Log\AbstractLogger;
7
use React\EventLoop\LoopInterface;
8
use React\Stream\WritableResourceStream;
9
use React\Stream\WritableStreamInterface;
10
use function WyriHaximus\PSR3\checkCorrectLogLevel;
11
use function WyriHaximus\PSR3\processPlaceHolders;
12
13
final class StdioLogger extends AbstractLogger
14
{
15
    const NEW_LINE = PHP_EOL;
16
17
    /**
18
     * @var Stdio
19
     */
20
    private $stdio;
21
22
    /**
23
     * @var bool
24
     */
25
    private $hideLevel = false;
26
27
    /**
28
     * @var bool
29
     */
30
    private $newLine = false;
31
32
    /**
33
     * @param WritableStreamInterface $stream
34
     *
35
     * @internal
36
     */
37 19
    public function __construct(WritableStreamInterface $stream)
38
    {
39 19
        $this->stdio = $stream;
0 ignored issues
show
Documentation Bug introduced by
It seems like $stream of type object<React\Stream\WritableStreamInterface> is incompatible with the declared type object<Clue\React\Stdio\Stdio> of property $stdio.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40 19
    }
41
42
    /**
43
     * @param LoopInterface $loop
44
     */
45 2
    public static function create(LoopInterface $loop): StdioLogger
46
    {
47 2
        return new self(new WritableResourceStream(STDOUT, $loop));
48
    }
49
50 2
    public function withHideLevel(bool $hideLevel): StdioLogger
51
    {
52 2
        $clone = clone $this;
53 2
        $clone->hideLevel = $hideLevel;
54
55 2
        return $clone;
56
    }
57
58 2
    public function withNewLine(bool $newLine): StdioLogger
59
    {
60 2
        $clone = clone $this;
61 2
        $clone->newLine = $newLine;
62
63 2
        return $clone;
64
    }
65
66 18
    public function log($level, $message, array $context = [])
67
    {
68 18
        checkCorrectLogLevel($level);
69 17
        $message = (string)$message;
70 17
        $message = processPlaceHolders($message, $context);
71 17
        if ($this->hideLevel === false) {
72 15
            $message = $level . ' ' . $message;
73
        }
74 17
        if ($this->newLine === true) {
75 2
            $message .= self::NEW_LINE;
76
        }
77 17
        $this->stdio->write($message);
78 17
    }
79
}
80