1414use Symfony \Component \Console \Output \OutputInterface ;
1515use Symfony \Component \Finder \Finder ;
1616
17- use function Termwind \render ;
1817use function Termwind \renderUsing ;
19- use function Termwind \terminal ;
2018
2119/**
2220 * @internal
@@ -118,15 +116,7 @@ public function handleOriginalArguments(array $arguments): void
118116 $ outputPath = explode ('= ' , $ argument )[1 ] ?? null ;
119117
120118 if (empty ($ outputPath )) {
121- render (<<<'HTML'
122- <div class="my-1">
123- <span class="ml-2 px-1 bg-red font-bold">ERROR</span>
124- <span class="ml-1">
125- No output path provided for [--profanity-json].
126- </span>
127- </div>
128- HTML);
129-
119+ Output::errorMessage ('No output path provided for [--profanity-json]. ' );
130120 $ this ->exit (1 );
131121 }
132122
@@ -137,14 +127,7 @@ public function handleOriginalArguments(array $arguments): void
137127 $ invalidLanguages = $ this ->validateLanguages ($ this ->language );
138128 if (! empty ($ invalidLanguages )) {
139129 $ invalidLangsStr = implode (', ' , $ invalidLanguages );
140- render (<<<HTML
141- <div class="my-1">
142- <span class="ml-2 px-1 bg-red font-bold">ERROR</span>
143- <span class="ml-1">
144- The specified language does not exist: {$ invalidLangsStr }
145- </span>
146- </div>
147- HTML );
130+ Output::errorMessage ("The specified language does not exist: $ invalidLangsStr " );
148131
149132 $ this ->output ->writeln (['' ]);
150133 $ this ->output ->writeln ('<info>Available languages:</info> ' );
@@ -163,14 +146,7 @@ public function handleOriginalArguments(array $arguments): void
163146 $ source = ConfigurationSourceDetector::detect ();
164147
165148 if ($ source === []) {
166- render (<<<'HTML'
167- <div class="my-1">
168- <span class="ml-2 px-1 bg-red font-bold">ERROR</span>
169- <span class="ml-1">
170- No source section found. Did you forget to add a `source` section to your `phpunit.xml` file?
171- </span>
172- </div>
173- HTML);
149+ Output::errorMessage ('No source section found. Did you forget to add a `source` section to your `phpunit.xml` file? ' );
174150
175151 $ this ->exit (1 );
176152 }
@@ -192,18 +168,10 @@ function (Result $result) use (&$filesWithProfanity, &$totalProfanities): void {
192168 $ path = str_replace (TestSuite::getInstance ()->rootPath .'/ ' , '' , $ result ->file );
193169 $ errors = $ result ->errors ;
194170
195- $ truncateAt = max (1 , terminal ()->width () - 24 );
196-
197171 if (empty ($ errors )) {
198172 if (! $ this ->compact ) {
199173 renderUsing ($ this ->output );
200- render (<<<HTML
201- <div class="flex mx-2">
202- <span class="truncate- {$ truncateAt }"> {$ path }</span>
203- <span class="flex-1 content-repeat-[.] text-gray mx-1"></span>
204- <span class="text-green">OK</span>
205- </div>
206- HTML );
174+ Output::pass ($ path );
207175
208176 $ this ->profanityLogger ->append ($ path , []);
209177 }
@@ -223,13 +191,7 @@ function (Result $result) use (&$filesWithProfanity, &$totalProfanities): void {
223191 $ profanityLines = implode (', ' , $ profanityLines );
224192
225193 renderUsing ($ this ->output );
226- render (<<<HTML
227- <div class="flex mx-2">
228- <span class="truncate- {$ truncateAt }"> {$ path }</span>
229- <span class="flex-1 content-repeat-[.] text-gray mx-1"></span>
230- <span class="text-red"> {$ profanityLines }</span>
231- </div>
232- HTML );
194+ Output::fail ($ path , $ profanityLines );
233195 }
234196 },
235197 $ this ->excludeWords ,
@@ -243,23 +205,9 @@ function (Result $result) use (&$filesWithProfanity, &$totalProfanities): void {
243205 $ this ->profanityLogger ->output ();
244206
245207 if ($ exitCode === 1 ) {
246- render (<<<HTML
247- <div class="my-1">
248- <span class="ml-2 px-1 bg-red font-bold">ERROR</span>
249- <span class="ml-1">
250- Found {$ totalProfanities } instances of profanity in {$ filesWithProfanityCount } files
251- </span>
252- </div>
253- HTML );
208+ Output::errorMessage ("Found $ totalProfanities instances of profanity in $ filesWithProfanityCount files " );
254209 } else {
255- render (<<<'HTML'
256- <div class="my-1">
257- <span class="ml-2 px-1 bg-green font-bold">PASS</span>
258- <span class="ml-1">
259- No profanity found in your application!
260- </span>
261- </div>
262- HTML);
210+ Output::successMessage ('No profanity found in your application! ' );
263211 }
264212
265213 $ this ->output ->writeln (['' ]);
0 commit comments