Pad the string to a certain length with another string.

@param int    $length Length to which to pad.
@param string $padString String that will be appended.

@throws StringObjectException
@return $this
349616
public function padBoth($length, $padString)
    {
        if (!$this->isNumber($length)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                '$length',
                'integer'
            ]);
        }

        if (!$this->isString($padString)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                '$padString',
                'string'
            ]);
        }

        $this->val(str_pad($this->val(), $length, $padString, STR_PAD_BOTH));

        return $this;
    }
131360
public function pad($length = 0, $chars = ' ', $type = STR_PAD_BOTH)
    {
        return new static(str_pad($this->subject, $length, $chars, $type));
    }
1311613
public function truncate($length)
    {
        $this->_text = StringHelper::truncate($this->_text, $length);
        
        return $this;
    }
1351859
public function padding(int $lenght, string $char = self::BLANK_TEXT, int $mode = STR_PAD_RIGHT): Text
    {
        return new static(str_pad($this->text, $lenght, $char, $mode));
    }
154038
public static function padLeft(string $str, int $length, string $with = ' ', string $encoding = null) : string
    {
        return static::pad($str, $length, $with, STR_PAD_LEFT, $encoding);
    }
363177
function padString(str, len) {
  return str.split().concat(new Array(len-str.length)).join(' ');
}
105732
public function setPadding()
    {
        $paddings = \func_get_args();

        if(count($paddings) === 1 && is_string(current($paddings)))
        {
            $paddings = explode(' ', current($paddings));
        }


        $paddingLabels = array('padding-top', 'padding-right', 'padding-bottom', 'padding-left');
        $this->setComposeAttribute($paddingLabels, $paddings);

        return $this;
    }
348974
public function padRight($length, $padString)
    {
        if (!$this->isNumber($length)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                '$length',
                'integer'
            ]);
        }

        if (!$this->isString($padString)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                '$padString',
                'string'
            ]);
        }

        $this->val(str_pad($this->val(), $length, $padString, STR_PAD_RIGHT));

        return $this;
    }
371210
protected function padString($string, $blockSize = 32)
    {
        $paddingSize = $blockSize - (strlen($string) % $blockSize);
        $string      .= str_repeat(chr($paddingSize), $paddingSize);

        return $string;
    }
964443
protected static function strPad($input, $padLen, $padStr = ' ', $padType = STR_PAD_RIGHT){
    $diff = strlen($input) - static::strLen($input);
    return str_pad($input, $padLen + $diff, $padStr, $padType);
  }
25093
public static function pad($text, $width, $pad = ' ', $mode = STR_PAD_RIGHT)
    {
        $width = strlen($text) - mb_strlen($text, 'UTF-8') + $width;
        return str_pad($text, $width, $pad, $mode);
    }
1317836
function padEnd(str, length) {
  /* istanbul ignore next */
  if (str.length >= length) return str;
  return str + ' '.repeat(length - str.length);
}
540387
public function rightPad(int $length, string $character = ' '): self
    {
        return $this->pad($length, $character, self::PAD_RIGHT);
    }
1188458
protected function padTrim($input, $pad = '0', $length = 3, $mode = STR_PAD_LEFT)
    {
        // Make sure we have a string.
        if (!is_string($input)) {
            $input = (string) $input;
        }

        return substr(str_pad($input, $length, $pad, $mode), 0, $length);
    }
948276
protected function pad($string, $len)
    {
        $strlen = $this->strlen($string);
        if ($strlen > $len) return $string;

        $pad = $len - $strlen;
        return $string . str_pad('', $pad, ' ');
    }
1168151
public function length($length = 2)
    {
        $this->length = (int) $length;
        $this->initials = $this->generateInitials();

        return $this;
    }
11395
public static function pad(
        $string,
        $length = 0,
        $substring = ' ',
        $encoding = null
    ) {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;
        $strLength = Mbstring::strlen($string, $encoding);
        $padding = $length - $strLength;

        return static::doPad($string, (int) floor($padding / 2), (int) ceil($padding / 2), $substring, $encoding);
    }