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.

Printer::printBuffer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* (c) Anton Medvedev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Deployer\ProcessRunner;
12
13
use Deployer\Host\Host;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
class Printer
17
{
18
    private OutputInterface $output;
19
20
    public function __construct(OutputInterface $output)
21
    {
22
        $this->output = $output;
23
    }
24
25
    public function command(Host $host, string $type, string $command): void
26
    {
27
        // -v for run command
28
        if ($this->output->isVerbose()) {
29
            $this->output->writeln("[$host] <fg=green;options=bold>$type</> $command");
30
        }
31
    }
32
33
    /**
34
     * Returns a callable for use with the symfony Process->run($callable) method.
35
     *
36
     * @return callable A function expecting a int $type (e.g. Process::OUT or Process::ERR) and string $buffer parameters.
37
     */
38
    public function callback(Host $host, bool $forceOutput): callable
39
    {
40
        return function ($type, $buffer) use ($forceOutput, $host) {
41
            if ($this->output->isVerbose() || $forceOutput) {
42
                $this->printBuffer($type, $host, $buffer);
43
            }
44
        };
45
    }
46
47
    /**
48
     * @param string $type Process::OUT or Process::ERR
49
     */
50
    public function printBuffer(string $type, Host $host, string $buffer): void
51
    {
52
        foreach (explode("\n", rtrim($buffer)) as $line) {
53
            $this->writeln($type, $host, $line);
54
        }
55
    }
56
57
    public function writeln(string $type, Host $host, string $line): void
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

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

57
    public function writeln(/** @scrutinizer ignore-unused */ string $type, Host $host, string $line): void

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

Loading history...
58
    {
59
        // Omit empty lines
60
        if (empty($line)) {
61
            return;
62
        }
63
64
        $this->output->writeln("[$host] $line");
65
    }
66
}
67