class Pad extends StringMutator (View source)

Pads a string to a given length with another string with specified direction.

Traits

Properties

protected $encoding from  UsesEncoding

Methods

__construct(int $length, string $string = ' ', StringDirection $direction = StringDirection::Right, string $encoding = null)

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static Pad
both(int $length, string $string = ' ', string $encoding = null)

No description

string|null
getEncoding(string $input = null)

No description

static Pad
left(int $length, string $string = ' ', string $encoding = null)

No description

static Pad
make(int $length, string $string = ' ', StringDirection $direction = StringDirection::Right, string $encoding = null)

No description

mixed
mutate(mixed $value)

Mutate the input value.

string
mutateString(string $value)

No description

string
resolveStringInput(mixed $value)

No description

static Pad
right(int $length, string $string = ' ', string $encoding = null)

No description

void
setEncoding(string|null $encoding)

No description

void
validateEncoding(string|null $encoding)

No description

Details

__construct(int $length, string $string = ' ', StringDirection $direction = StringDirection::Right, string $encoding = null)

No description

Parameters

int $length

The length to pad to.

string $string

The string to pad with (default: ' ').

StringDirection $direction

The direction to pad in (default: StringDirection::Right).

string $encoding

The encoding to use (optional).

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static Pad both(int $length, string $string = ' ', string $encoding = null)

No description

Parameters

int $length

The length to pad to.

string $string

The string to pad with (default: ' ').

string $encoding

The encoding to use (optional).

Return Value

Pad

protected string|null getEncoding(string $input = null)

No description

Parameters

string $input

Return Value

string|null

static Pad left(int $length, string $string = ' ', string $encoding = null)

No description

Parameters

int $length

The length to pad to.

string $string

The string to pad with (default: ' ').

string $encoding

The encoding to use (optional).

Return Value

Pad

static Pad make(int $length, string $string = ' ', StringDirection $direction = StringDirection::Right, string $encoding = null)

No description

Parameters

int $length

The length to pad to.

string $string

The string to pad with (default: ' ').

StringDirection $direction

The direction to pad in (default: StringDirection::Right).

string $encoding

The encoding to use (optional).

Return Value

Pad

final mixed mutate(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

protected string mutateString(string $value)

No description

Parameters

string $value

Return Value

string

protected string resolveStringInput(mixed $value)

No description

Parameters

mixed $value

Return Value

string

static Pad right(int $length, string $string = ' ', string $encoding = null)

No description

Parameters

int $length

The length to pad to.

string $string

The string to pad with (default: ' ').

string $encoding

The encoding to use (optional).

Return Value

Pad

protected void setEncoding(string|null $encoding)

No description

Parameters

string|null $encoding

Return Value

void

protected void validateEncoding(string|null $encoding)

No description

Parameters

string|null $encoding

Return Value

void