public static function wrapText($text, $indent = 0, $width = 0): string
    {
        if (!$text) {
            return $text;
        }

        if ((int)$width <= 0) {
            $size = Sys::getScreenSize();

            if ($size === false || $size[0] <= $indent) {
                return $text;
            }

            $width = $size[0];
        }

        $pad = \str_repeat(' ', $indent);
        $lines = \explode("\n", \wordwrap($text, $width - $indent, "\n", true));
        $first = true;

        foreach ($lines as $i => $line) {
            if ($first) {
                $first = false;
                continue;
            }
            $lines[$i] = $pad . $line;
        }

        return $pad . '  ' . \implode("\n", $lines);
    }
public static function wrapText($text, $indent = 0, $width = 0): string
    {
        if (!$text) {
            return $text;
        }

        if ((int)$width <= 0) {
            $size = Sys::getScreenSize();

            if ($size === false || $size[0] <= $indent) {
                return $text;
            }

            $width = $size[0];
        }

        $pad = \str_repeat(' ', $indent);
        $lines = \explode("\n", \wordwrap($text, $width - $indent, "\n", true));
        $first = true;

        foreach ($lines as $i => $line) {
            if ($first) {
                $first = false;
                continue;
            }
            $lines[$i] = $pad . $line;
        }

        return $pad . '  ' . \implode("\n", $lines);
    }
public static function wrapText ( $ text , $ indent = 0 , $ width = 0 ) : string { if ( ! $ text ) { return $ text ; } if ( ( int ) $ width <= 0 ) { $ size = Sys :: getScreenSize ( ) ; if ( $ size === false || $ size [ 0 ] <= $ indent ) { return $ text ; } $ width = $ size [ 0 ] ; } $ pad = \ str_repeat ( ' ' , $ indent ) ; $ lines = \ explode ( "\n" , \ wordwrap ( $ text , $ width - $ indent , "\n" , true ) ) ; $ first = true ; foreach ( $ lines as $ i => $ line ) { if ( $ first ) { $ first = false ; continue ; } $ lines [ $ i ] = $ pad . $ line ; } return $ pad . '  ' . \ implode ( "\n" , $ lines ) ; }
Word wrap text with indentation to fit the screen size

If screen size could not be detected, or the indentation is greater than the screen size, the text will not be wrapped.

The first line will **not** be indented, so `wrapText("Lorem ipsum dolor sit amet.", 4)` will result in the
following output, given the screen width is 16 characters:

```
Lorem ipsum
dolor sit
amet.
```

@param string  $text the text to be wrapped
@param integer $indent number of spaces to use for indentation.
@param integer $width
@return string the wrapped text.
@from yii2
Word wrap text with indentation to fit the screen size