Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
CommandProcess | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
mustRunWithOutput | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
runWithOutput | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
makeCallback | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Copyright (C) 2018 Kunal Mehta <legoktm@debian.org> |
4 | * |
5 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation, either version 3 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | namespace MediaWiki\Tool\PatchCoverage; |
20 | |
21 | use Symfony\Component\Console\Output\OutputInterface; |
22 | use Symfony\Component\Process\Process; |
23 | |
24 | /** |
25 | * Wrapper around Process that prints output |
26 | * to the console live |
27 | */ |
28 | class CommandProcess extends Process { |
29 | |
30 | /** |
31 | * @param OutputInterface $output |
32 | */ |
33 | public function mustRunWithOutput( OutputInterface $output ) { |
34 | $output->writeln( '$ ' . $this->getCommandLine() ); |
35 | $this->mustRun( $this->makeCallback( $output ) ); |
36 | } |
37 | |
38 | /** |
39 | * @param OutputInterface $output |
40 | */ |
41 | public function runWithOutput( OutputInterface $output ) { |
42 | $output->writeln( '$ ' . $this->getCommandLine() ); |
43 | $this->run( $this->makeCallback( $output ) ); |
44 | } |
45 | |
46 | /** |
47 | * @param OutputInterface $output |
48 | * |
49 | * @return \Closure |
50 | */ |
51 | private function makeCallback( OutputInterface $output ) { |
52 | return static function ( $type, $buffer ) use ( $output ) { |
53 | $output->write( $buffer ); |
54 | }; |
55 | } |
56 | } |