1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of graze/parallel-process. |
4
|
|
|
* |
5
|
|
|
* Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/graze/parallel-process/blob/master/LICENSE.md |
11
|
|
|
* @link https://github.com/graze/parallel-process |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Graze\ParallelProcess\Test; |
15
|
|
|
|
16
|
|
|
use Graze\DiffRenderer\DiffConsoleOutput; |
17
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput; |
18
|
|
|
|
19
|
|
|
class BufferDiffOutput extends DiffConsoleOutput |
20
|
|
|
{ |
21
|
|
|
/** @var array */ |
22
|
|
|
protected $written; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* BufferDiffOutput constructor. |
26
|
|
|
*/ |
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
$dummy = new ConsoleOutput(); |
30
|
|
|
parent::__construct($dummy); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param array|string $messages |
35
|
|
|
* @param bool $newline |
36
|
|
|
* @param int $options |
37
|
|
|
*/ |
38
|
|
|
public function write($messages, $newline = false, $options = 0) |
39
|
|
|
{ |
40
|
|
|
$messages = (array) $messages; |
41
|
|
|
$this->written[] = $messages; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param array|string $messages |
46
|
|
|
* @param int $options |
47
|
|
|
*/ |
48
|
|
|
public function writeln($messages, $options = 0) |
49
|
|
|
{ |
50
|
|
|
$messages = (array) $messages; |
51
|
|
|
$this->written[] = $messages; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string|\string[] $messages |
56
|
|
|
* @param bool $newline |
57
|
|
|
* @param int $options |
58
|
|
|
*/ |
59
|
|
|
public function reWrite($messages, $newline = false, $options = 0) |
60
|
|
|
{ |
61
|
|
|
$messages = (array) $messages; |
62
|
|
|
$this->written[] = $messages; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
public function getWritten() |
69
|
|
|
{ |
70
|
|
|
return $this->written; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|