class Truncate extends StringMutator (View source)

Truncate a string to a given length. Appends the provided ellipsis to the end of the string if it is truncated.

Traits

Methods

__construct(int $length, string $ellipsis = '...')

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static Truncate
make(int $length, string $ellipsis = '...')

No description

mixed
mutate(mixed $value)

Mutate the input value.

string
mutateString(string $value)

No description

string
resolveStringInput(mixed $value)

No description

Details

__construct(int $length, string $ellipsis = '...')

No description

Parameters

int $length

The maximum length of the string.

string $ellipsis

The ellipsis to append to the string if it is truncated (default: '...').

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static Truncate make(int $length, string $ellipsis = '...')

No description

Parameters

int $length

The maximum length of the string.

string $ellipsis

The ellipsis to append to the string if it is truncated (default: '...').

Return Value

Truncate

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