ParallelConsoleOutput.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Illuminate\Testing;
use Illuminate\Support\Str;
use Symfony\Component\Console\Output\ConsoleOutput;
class ParallelConsoleOutput extends ConsoleOutput
{
/**
* The original output instance.
*
* @var \Symfony\Component\Console\Output\OutputInterface
*/
protected $output;
/**
* The output that should be ignored.
*
* @var array
*/
protected $ignore = [
'Running phpunit in',
'Configuration read from',
];
/**
* Create a new Parallel ConsoleOutput instance.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return void
*/
public function __construct($output)
{
parent::__construct(
$output->getVerbosity(),
$output->isDecorated(),
$output->getFormatter(),
);
$this->output = $output;
}
/**
* Writes a message to the output.
*
* @param string|iterable $messages
* @param bool $newline
* @param int $options
* @return void
*/
public function write($messages, bool $newline = false, int $options = 0)
{
$messages = collect($messages)->filter(function ($message) {
return ! Str::contains($message, $this->ignore);
});
$this->output->write($messages->toArray(), $newline, $options);
}
}