Completed
Push — master ( 32cca7...5650e8 )
by Jonathan
15s
created

OutputWriter::getLastMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations;
6
7
/**
8
 * The OutputWriter class is responsible for writing output to the command line when executing migrations.
9
 */
10
class OutputWriter
11
{
12
    /** @var callable */
13
    private $callback;
14
15
    /** @var string */
16
    private $lastMessage = '';
17
18 197
    public function __construct(?callable $callback = null)
19
    {
20 197
        if ($callback === null) {
21
            $callback = function (string $message) : void {
22 41
                $this->lastMessage = $message;
23 168
            };
24
        }
25
26 197
        $this->callback = $callback;
27 197
    }
28
29 18
    public function setCallback(callable $callback) : void
30
    {
31 18
        $this->callback = $callback;
32 18
    }
33
34 63
    public function write(string $message) : void
35
    {
36 63
        ($this->callback)($message);
37 63
    }
38
39 1
    public function getLastMessage() : string
40
    {
41 1
        return $this->lastMessage;
42
    }
43
}
44