Completed
Push — master ( 368556...6bf94b )
by Jonathan
11s
created

OutputWriter::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations;
6
7
class OutputWriter
8
{
9
    /** @var callable */
10
    private $callback;
11
12 182
    public function __construct(?callable $callback = null)
13
    {
14 182
        if ($callback === null) {
15
            $callback = function ($message) : void {
0 ignored issues
show
Unused Code introduced by
The parameter $message 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

15
            $callback = function (/** @scrutinizer ignore-unused */ $message) : 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...
16 151
            };
17
        }
18
19 182
        $this->callback = $callback;
20 182
    }
21
22 16
    public function setCallback(callable $callback) : void
23
    {
24 16
        $this->callback = $callback;
25 16
    }
26
27 61
    public function write(string $message) : void
28
    {
29 61
        ($this->callback)($message);
30 61
    }
31
}
32