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.

Logger   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 76.19%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 47
c 0
b 0
f 0
rs 10
ccs 16
cts 21
cp 0.7619
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 3 1
A callback() 0 4 1
A __construct() 0 3 1
A printBuffer() 0 4 2
A writeln() 0 16 3
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Logger;
9
10
use Deployer\Component\ProcessRunner\Printer;
11
use Deployer\Host\Host;
12
use Deployer\Logger\Handler\HandlerInterface;
13
use Symfony\Component\Process\Process;
14
15
class Logger
16
{
17
    /**
18
     * @var HandlerInterface
19
     */
20
    private $handler;
21
22 14
    public function __construct(HandlerInterface $handler)
23
    {
24 14
        $this->handler = $handler;
25 14
    }
26
27 9
    public function log(string $message)
28
    {
29 9
        $this->handler->log("$message\n");
30 9
    }
31
32
    public function callback(Host $host)
33
    {
34
        return function ($type, $buffer) use ($host) {
35
            $this->printBuffer($type, $host, $buffer);
0 ignored issues
show
Bug introduced by
$host of type Deployer\Host\Host is incompatible with the type string expected by parameter $type of Deployer\Logger\Logger::printBuffer(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
            $this->printBuffer($type, /** @scrutinizer ignore-type */ $host, $buffer);
Loading history...
36
        };
37
    }
38
39 9
    public function printBuffer(Host $host, string $type, string $buffer)
40
    {
41 9
        foreach (explode("\n", rtrim($buffer)) as $line) {
42 9
            $this->writeln($host, $type, $line);
43
        }
44 9
    }
45
46 9
    public function writeln(Host $host, string $type, string $line)
47
    {
48 9
        $line = Printer::filterOutput($line);
49
50
        // Omit empty lines
51 9
        if (empty($line)) {
52
            return;
53
        }
54
55 9
        if ($type === Process::ERR) {
56
            $line = "[{$host->getAlias()}] err $line";
57
        } else {
58 9
            $line = "[{$host->getAlias()}] $line";
59
        }
60
61 9
        $this->log($line);
62 9
    }
63
}
64