src/Output/CodeFormatter.php
public function formatCode(string $code, $enableColors): string
    {
        $block = [];
        $codeLines = explode("\n", $code);

        $this->enableColors = (bool)$enableColors;
        $this->numberOfLines = count($codeLines);
        $this->gutterWidth = strlen((string)$this->numberOfLines) + 1;

        $i = 0;
        foreach ($codeLines as $lineNumber => $line) {
            $i += 1;
            $this->prepareCodeLine($line, $block, $i);
        }

        return "\n" . $this->colorize(
                self::NORMAL . self::LIGHT_GRAY_BACKGROUND . self::WHITE,
                implode("\n", $block),
                self::RED
            );
    }
public function formatCode(string $code, $enableColors): string
    {
        $block = [];
        $codeLines = explode("\n", $code);

        $this->enableColors = (bool)$enableColors;
        $this->numberOfLines = count($codeLines);
        $this->gutterWidth = strlen((string)$this->numberOfLines) + 1;

        $i = 0;
        foreach ($codeLines as $lineNumber => $line) {
            $i += 1;
            $this->prepareCodeLine($line, $block, $i);
        }

        return "\n" . $this->colorize(
                self::NORMAL . self::LIGHT_GRAY_BACKGROUND . self::WHITE,
                implode("\n", $block),
                self::RED
            );
    }
public function formatCode ( string $ code , $ enableColors ) : string { $ block = [ ] ; $ codeLines = explode ( "\n" , $ code ) ; $ this -> enableColors = ( bool ) $ enableColors ; $ this -> numberOfLines = count ( $ codeLines ) ; $ this -> gutterWidth = strlen ( ( string ) $ this -> numberOfLines ) + 1 ; $ i = 0 ; foreach ( $ codeLines as $ lineNumber => $ line ) { $ i += 1 ; $ this -> prepareCodeLine ( $ line , $ block , $ i ) ; } return "\n" . $ this -> colorize ( self :: NORMAL . self :: LIGHT_GRAY_BACKGROUND . self :: WHITE , implode ( "\n" , $ block ) , self :: RED ) ; }
Formats the given code

@example
$formatter = new \Cundd\TestFlight\Output\CodeFormatter(
new \Cundd\TestFlight\Cli\WindowHelper()
);
test_flight_assert_same('1 line 1', trim($formatter->formatCode('line 1', false)));
@param string $code
@param bool   $enableColors
@return string
Formats the given code