Documentation

StringHelper
in package

FinalYes

String manipulation utility class.

Provides string helper methods including trimming (with full-width space support), empty checking, and text ellipsis truncation.

Table of Contents

Methods

ellipsis()  : string
Truncate a long string with ellipsis in the middle.
empty()  : bool
Check if a string is empty after trimming whitespace.
trim()  : string
Trim whitespace from both ends of a string.

Methods

ellipsis()

Truncate a long string with ellipsis in the middle.

public static ellipsis(string $str[, int $length = 100 ]) : string

Preserves the beginning and end of the string, replacing the middle portion with "..." when the string exceeds the max length.

Parameters
$str : string

Input string.

$length : int = 100

Maximum character length. Default is 100.

Return values
string

Truncated string, or original if within length.

empty()

Check if a string is empty after trimming whitespace.

public static empty(string|null $str) : bool
Parameters
$str : string|null

Input string.

Return values
bool

True if the trimmed string is empty.

trim()

Trim whitespace from both ends of a string.

public static trim(string|null $str) : string

Handles standard whitespace characters plus full-width spaces.

Parameters
$str : string|null

Input string.

Return values
string

Trimmed string.


        
On this page

Search results