src/StringBuilder.php
public function setLength($newLength, $padding = ' ')
    {
        $newLength     = (int) $newLength;
        $currentLength = $this->length();

        if ($newLength != $currentLength) {
            while ($newLength > $this->length()) {
                $this->string .= $padding;
            }
            if ($newLength < $this->length()) {
                $this->string = mb_substr($this->string, 0, $newLength, $this->encoding);
            }
        }

        return $this;
    }
public function setLength($newLength, $padding = ' ')
    {
        $newLength     = (int) $newLength;
        $currentLength = $this->length();

        if ($newLength != $currentLength) {
            while ($newLength > $this->length()) {
                $this->string .= $padding;
            }
            if ($newLength < $this->length()) {
                $this->string = mb_substr($this->string, 0, $newLength, $this->encoding);
            }
        }

        return $this;
    }
Set the length of this sequence.

If the sequence is shorter, than it will be pad with spaces.

@param int    $newLength The new length.
@param string $padding   The padding sequence.

@return StringBuilder