Stringy\Stringy::padBoth PHP Method

padBoth() public method

Returns a new string of a given length such that both sides of the string are padded. Alias for pad() with a $padType of 'both'.
public padBoth ( integer $length, string $padStr = ' ' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
return Stringy String with padding applied
    public function padBoth($length, $padStr = ' ')
    {
        $padding = $length - $this->length();
        return $this->applyPadding(floor($padding / 2), ceil($padding / 2), $padStr);
    }