File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
src/PHPUnit/Cobertura/Formatter Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,13 @@ final class Application
2828 private const int EXIT_CODE_ERROR = 1 ;
2929
3030 private ConsoleOutput $ consoleOutput ;
31+ private CommandLine $ commandLine ;
3132 private Stats $ stats ;
3233
3334 public function __construct ()
3435 {
3536 $ this ->consoleOutput = new ConsoleOutput ();
37+ $ this ->commandLine = new CommandLine ();
3638 $ this ->stats = new Stats ();
3739 }
3840
@@ -60,13 +62,24 @@ public function run(): int
6062 */
6163 private function doRun (): int
6264 {
63- $ cmd = new CommandLine ();
64- if ($ cmd ->optionInit ()) {
65+ $ this ->consoleOutput ->getFormatter ()->setDecorated (!$ this ->commandLine ->optionNoColor ());
66+
67+ if ($ this ->commandLine ->optionInit ()) {
6568 (new Creator ())->create ();
6669
6770 return self ::EXIT_CODE_OK ;
6871 }
6972
73+ $ this ->parseAndRender ();
74+
75+ return self ::EXIT_CODE_OK ;
76+ }
77+
78+ /**
79+ * @throws Exception
80+ */
81+ private function parseAndRender (): void
82+ {
7083 (new Renderer (
7184 $ this ->consoleOutput ,
7285 new Colorizer (
@@ -75,12 +88,10 @@ private function doRun(): int
7588 ))->render (
7689 (new Parser ())->parse (
7790 new CoberturaFile (
78- $ cmd ->coberturaFile ()
91+ $ this -> commandLine ->coberturaFile ()
7992 )
8093 )
8194 );
82-
83- return self ::EXIT_CODE_OK ;
8495 }
8596
8697 private function message (string $ message ): void
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ public function buildArgvInput(): ArgvInput
3636 $ option = new InputOption ('init ' , null , InputOption::VALUE_NONE );
3737 $ definition ->addOption ($ option );
3838
39+ $ option = new InputOption ('no-color ' , null , InputOption::VALUE_NONE );
40+ $ definition ->addOption ($ option );
41+
3942 return new ArgvInput (null , $ definition );
4043 }
4144
@@ -54,4 +57,9 @@ public function optionInit(): bool
5457 {
5558 return (bool ) $ this ->input ->getOption ('init ' );
5659 }
60+
61+ public function optionNoColor (): bool
62+ {
63+ return (bool ) $ this ->input ->getOption ('no-color ' );
64+ }
5765}
You can’t perform that action at this time.
0 commit comments