src/Util/Utf8String.php
public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
    {
        if ($side === STR_PAD_BOTH) {
            $length -= $this->count();

            if ($length <= 0) {
                return $this;
            }

            $left = (int) ($length / 2);
            $right = $length - $left;

            $this->_string = Strings::padRight(
                Strings::padLeft($this->_string, $left, $piece),
                $right, $piece
            );
        } elseif (STR_PAD_LEFT === $side) {
            $this->_string = Strings::padLeft($this->_string, $length, $piece);
        } else {
            $this->_string = Strings::padRight($this->_string, $length, $piece);
        }

        return $this;
    }
public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
    {
        if ($side === STR_PAD_BOTH) {
            $length -= $this->count();

            if ($length <= 0) {
                return $this;
            }

            $left = (int) ($length / 2);
            $right = $length - $left;

            $this->_string = Strings::padRight(
                Strings::padLeft($this->_string, $left, $piece),
                $right, $piece
            );
        } elseif (STR_PAD_LEFT === $side) {
            $this->_string = Strings::padLeft($this->_string, $length, $piece);
        } else {
            $this->_string = Strings::padRight($this->_string, $length, $piece);
        }

        return $this;
    }
public function pad ( int $ length , string $ piece = ' ' , int $ side = STR_PAD_RIGHT ) { if ( $ side === STR_PAD_BOTH ) { $ length -= $ this -> count ( ) ; if ( $ length <= 0 ) { return $ this ; } $ left = ( int ) ( $ length / 2 ) ; $ right = $ length - $ left ; $ this -> _string = Strings :: padRight ( Strings :: padLeft ( $ this -> _string , $ left , $ piece ) , $ right , $ piece ) ; } elseif ( STR_PAD_LEFT === $ side ) { $ this -> _string = Strings :: padLeft ( $ this -> _string , $ length , $ piece ) ; } else { $ this -> _string = Strings :: padRight ( $ this -> _string , $ length , $ piece ) ; } return $ this ; }
Pad the current string to a certain length with another piece, aka piece.

@param   int    $length     Length.
@param   string $piece      Piece.
@param   int    $side       Whether we append at the end or the beginning
of the current string.

@return  self
Pad the current string to a certain length with another piece aka piece .