safeTruncate

Truncates the string to a given length, while ensuring that it does not split words.

Description

static safeTruncate(int $length, string $substring)

If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.

Parameters

  • int $length
    Desired length of the truncated string.

  • string $substring
    The substring to append if it can fit.

Return Value

static