Platformsh\Cli\Console\AdaptiveTable::wrapCell PHP Method

wrapCell() protected method

Word-wrap the contents of a cell, so that they fit inside a max width.
protected wrapCell ( string $contents, integer $width ) : string
$contents string
$width integer
return string
    protected function wrapCell($contents, $width)
    {
        // Account for left-indented cells.
        if (strpos($contents, ' ') === 0) {
            $trimmed = ltrim($contents, ' ');
            $indent = strlen($contents) - strlen($trimmed);
            return str_repeat(' ', $indent) . wordwrap($trimmed, $width - $indent, PHP_EOL, true);
        }
        return wordwrap($contents, $width, PHP_EOL, true);
    }