Stringy\Stringy::pad PHP Method

pad() public method

Pads the string to a given length with $padStr. If length is less than or equal to the length of the string, no padding takes places. The default string used for padding is a space, and the default type (one of 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException if $padType isn't one of those 3 values.
public pad ( integer $length, string $padStr = ' ', string $padType = 'right' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
$padType string One of 'left', 'right', 'both'
return Stringy Object with a padded $str
    public function pad($length, $padStr = ' ', $padType = 'right')
    {
        if (!in_array($padType, array('left', 'right', 'both'))) {
            throw new InvalidArgumentException('Pad expects $padType ' . "to be one of 'left', 'right' or 'both'");
        }
        switch ($padType) {
            case 'left':
                return $this->padLeft($length, $padStr);
            case 'right':
                return $this->padRight($length, $padStr);
            default:
                return $this->padBoth($length, $padStr);
        }
    }