public function getColoredStringReadLine(
        string $string,
        string $foreground_color = null,
        string $background_color = null
    ):string {
        $string = $this->resizeContent($string, 0);
        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

        // Add string and end coloring
        $colored_string .=  $string . "\033[0m";

        return ($colored_string);
    }
public function getColoredStringReadLine(
        string $string,
        string $foreground_color = null,
        string $background_color = null
    ):string {
        $string = $this->resizeContent($string, 0);
        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

        // Add string and end coloring
        $colored_string .=  $string . "\033[0m";

        return ($colored_string);
    }
public function getColoredStringReadLine ( string $ string , string $ foreground_color = null , string $ background_color = null ) : string { $ string = $ this -> resizeContent ( $ string , 0 ) ; $ colored_string = "" ; // Check if given foreground color found if ( isset ( $ this -> foreground_colors [ $ foreground_color ] ) ) { $ colored_string .= "\033[" . $ this -> foreground_colors [ $ foreground_color ] . "m" ; } // Check if given background color found if ( isset ( $ this -> background_colors [ $ background_color ] ) ) { $ colored_string .= "\033[" . $ this -> background_colors [ $ background_color ] . "m" ; } // Add string and end coloring $ colored_string .= $ string . "\033[0m" ; return ( $ colored_string ) ; }
Return colored string for readline action
@param string $string message
@param string|null $foreground_color Foreground color
@param string|null $background_color Background color
@return string Colored string
Return colored string for readline action