SqlParser\Tools\ContextGenerator::printWords PHP Метод

printWords() публичный статический Метод

Prints an array of a words in PHP format.
public static printWords ( array $words, integer $spaces = 8, integer $line = 80 ) : string
$words array The list of words to be formatted.
$spaces integer The number of spaces that starts every line.
$line integer The length of a line.
Результат string
    public static function printWords($words, $spaces = 8, $line = 80)
    {
        $ret = '';
        foreach ($words as $type => $wordsByType) {
            foreach ($wordsByType as $len => $wordsByLen) {
                $count = round(($line - $spaces) / ($len + 9));
                // strlen("'' => 1, ") = 9
                $i = 0;
                foreach ($wordsByLen as $word) {
                    if ($i == 0) {
                        $ret .= str_repeat(' ', $spaces);
                    }
                    $ret .= "'" . $word . "' => " . $type . ', ';
                    if (++$i == $count) {
                        $ret .= "\n";
                        $i = 0;
                    }
                }
                if ($i != 0) {
                    $ret .= "\n";
                }
            }
            $ret .= "\n";
        }
        // Trim trailing spaces and return.
        return str_replace(" \n", "\n", $ret);
    }