protected function applyPadding($left = 0, $right = 0, $padStr = ' ')
    {
        $length = UTF8::strlen($padStr, $this->encoding);
        $strLength = $this->getLength();
        $paddedLength = $strLength + $left + $right;

        if (!$length || $paddedLength <= $strLength) return $this;

        $leftPadding = UTF8::substr
        (
            UTF8::str_repeat($padStr, ceil($left / $length)),
            0,
            $left,
            $this->encoding
        );

        $rightPadding = UTF8::substr
        (
            UTF8::str_repeat($padStr, ceil($right / $length)),
            0,
            $right,
            $this->encoding
        );

        return $this->newSelf($leftPadding.$this->scalarString.$rightPadding);
    }
protected function applyPadding($left = 0, $right = 0, $padStr = ' ')
    {
        $length = UTF8::strlen($padStr, $this->encoding);
        $strLength = $this->getLength();
        $paddedLength = $strLength + $left + $right;

        if (!$length || $paddedLength <= $strLength) return $this;

        $leftPadding = UTF8::substr
        (
            UTF8::str_repeat($padStr, ceil($left / $length)),
            0,
            $left,
            $this->encoding
        );

        $rightPadding = UTF8::substr
        (
            UTF8::str_repeat($padStr, ceil($right / $length)),
            0,
            $right,
            $this->encoding
        );

        return $this->newSelf($leftPadding.$this->scalarString.$rightPadding);
    }
protected function applyPadding ( $ left = 0 , $ right = 0 , $ padStr = ' ' ) { $ length = UTF8 :: strlen ( $ padStr , $ this -> encoding ) ; $ strLength = $ this -> getLength ( ) ; $ paddedLength = $ strLength + $ left + $ right ; if ( ! $ length || $ paddedLength <= $ strLength ) return $ this ; $ leftPadding = UTF8 :: substr ( UTF8 :: str_repeat ( $ padStr , ceil ( $ left / $ length ) ) , 0 , $ left , $ this -> encoding ) ; $ rightPadding = UTF8 :: substr ( UTF8 :: str_repeat ( $ padStr , ceil ( $ right / $ length ) ) , 0 , $ right , $ this -> encoding ) ; return $ this -> newSelf ( $ leftPadding . $ this -> scalarString . $ rightPadding ) ; }
Pad internal helper, adds padding to the left and right of the string.

@param  int    $left   Length of left padding.

@param  int    $right  Length of right padding.

@param  string $padStr String used to pad, default is a space.

@return static         String with padding applied.
Pad internal helper adds padding to the left and right of the string .