Automattic\WooCommerce\Gateways\PayPal
Request::limit_length
Limit length of an arg.
Method of the class: Request{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->limit_length( $text, $limit ): string;
- $text(string) (required)
- Text to limit.
- $limit(int)
- Limit size in characters.
Default:127
Request::limit_length() Request::limit length code WC 10.8.1
private function limit_length( string $text, int $limit = 127 ): string {
$str_limit = $limit - 3;
if ( function_exists( 'mb_strimwidth' ) ) {
if ( mb_strlen( $text ) > $limit ) {
$text = mb_strimwidth( $text, 0, $str_limit ) . '...';
}
} elseif ( strlen( $text ) > $limit ) {
$text = substr( $text, 0, $str_limit ) . '...';
}
return $text;
}