@@ -363,192 +363,6 @@ function removeDirectory($dir): void
363363 }
364364 }
365365 }
366-
367- $ sequences = array_filter ($ sequences , function ($ val ) {
368- return $ val !== null ;
369- });
370-
371- if (empty ($ sequences )) {
372- return $ text ;
373- }
374-
375- return $ this ->escSequence (implode ('; ' , $ sequences )) . $ text . $ this ->escSequence (self ::RESET_STYLE );
376- }
377-
378- /**
379- * @param bool $forceStyle
380- */
381- public function setForceStyle ($ forceStyle )
382- {
383- $ this ->forceStyle = (bool ) $ forceStyle ;
384- }
385-
386- /**
387- * @return bool
388- */
389- public function isStyleForced ()
390- {
391- return $ this ->forceStyle ;
392- }
393-
394- /**
395- * @throws InvalidStyleException
396- * @throws \InvalidArgumentException
397- */
398- public function setThemes (array $ themes )
399- {
400- $ this ->themes = [];
401- foreach ($ themes as $ name => $ styles ) {
402- $ this ->addTheme ($ name , $ styles );
403- }
404- }
405-
406- /**
407- * @param string $name
408- * @param array|string $styles
409- *
410- * @throws \InvalidArgumentException
411- * @throws InvalidStyleException
412- */
413- public function addTheme ($ name , $ styles )
414- {
415- if (is_string ($ styles )) {
416- $ styles = [$ styles ];
417- }
418- if (! is_array ($ styles )) {
419- throw new \InvalidArgumentException ('Style must be string or array. ' );
420- }
421-
422- foreach ($ styles as $ style ) {
423- if (! $ this ->isValidStyle ($ style )) {
424- throw new InvalidStyleException ($ style );
425- }
426- }
427-
428- $ this ->themes [$ name ] = $ styles ;
429- }
430-
431- /**
432- * @return array
433- */
434- public function getThemes ()
435- {
436- return $ this ->themes ;
437- }
438-
439- /**
440- * @param string $name
441- * @return bool
442- */
443- public function hasTheme ($ name )
444- {
445- return isset ($ this ->themes [$ name ]);
446- }
447-
448- /**
449- * @param string $name
450- */
451- public function removeTheme ($ name )
452- {
453- unset($ this ->themes [$ name ]);
454- }
455-
456- /**
457- * @codeCoverageIgnore
458- *
459- * @return bool
460- */
461- public function isSupported ()
462- {
463- if (DIRECTORY_SEPARATOR === '\\' ) {
464- // phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
465- if (function_exists ('sapi_windows_vt100_support ' ) && @sapi_windows_vt100_support (STDOUT )) {
466- return true ;
467- } elseif (getenv ('ANSICON ' ) !== false || getenv ('ConEmuANSI ' ) === 'ON ' ) {
468- return true ;
469- }
470-
471- return false ;
472- } else {
473- // phpcs:ignore Generic.PHP.NoSilencedErrors
474- return function_exists ('posix_isatty ' ) && @posix_isatty (STDOUT );
475- }
476- }
477-
478- /**
479- * @codeCoverageIgnore
480- *
481- * @return bool
482- */
483- public function are256ColorsSupported ()
484- {
485- if (DIRECTORY_SEPARATOR === '\\' ) {
486- // phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
487- return function_exists ('sapi_windows_vt100_support ' ) && @sapi_windows_vt100_support (STDOUT );
488- } else {
489- return strpos (getenv ('TERM ' ), '256color ' ) !== false ;
490- }
491- }
492-
493- /**
494- * @return array
495- */
496- public function getPossibleStyles ()
497- {
498- return array_keys ($ this ->styles );
499- }
500-
501- /**
502- * @param string $name
503- * @return string[]
504- */
505- private function themeSequence ($ name )
506- {
507- $ sequences = [];
508- foreach ($ this ->themes [$ name ] as $ style ) {
509- $ sequences [] = $ this ->styleSequence ($ style );
510- }
511-
512- return $ sequences ;
366+ rmdir ($ dir );
513367 }
514-
515- /**
516- * @param string $style
517- * @return string
518- */
519- private function styleSequence ($ style )
520- {
521- if (array_key_exists ($ style , $ this ->styles )) {
522- return $ this ->styles [$ style ];
523- }
524-
525- if (! $ this ->are256ColorsSupported ()) {
526- return null ;
527- }
528-
529- preg_match (self ::COLOR256_REGEXP , $ style , $ matches );
530-
531- $ type = $ matches [1 ] === 'bg_ ' ? self ::BACKGROUND : self ::FOREGROUND ;
532- $ value = $ matches [2 ];
533-
534- return "$ type;5; $ value " ;
535- }
536-
537- /**
538- * @param string $style
539- * @return bool
540- */
541- private function isValidStyle ($ style )
542- {
543- return array_key_exists ($ style , $ this ->styles ) || preg_match (self ::COLOR256_REGEXP , $ style );
544- }
545-
546- /**
547- * @param string|int $value
548- * @return string
549- */
550- private function escSequence ($ value )
551- {
552- return "\033[ {$ value }m " ;
553- }
554- }
368+ }
0 commit comments