Automattic\WooCommerce\Gateways\PayPal
Request::limit_length
Limit length of an arg.
Метод класса: Request{}
Хуков нет.
Возвращает
Строку.
Использование
// private - только в коде основоного (родительского) класса $result = $this->limit_length( $text, $limit ): string;
- $text(строка) (обязательный)
- Text to limit.
- $limit(int)
- Limit size in characters.
По умолчанию:127
Код Request::limit_length() Request::limit length WC 11.0.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;
}