@@ -24,6 +24,16 @@ class Ascii extends Renderer {
2424 */
2525 private const VALID_WRAPPING_MODES = array ( 'wrap ' , 'word-wrap ' , 'truncate ' );
2626
27+ /**
28+ * Ellipsis character(s) used for truncation.
29+ */
30+ private const ELLIPSIS = '... ' ;
31+
32+ /**
33+ * Width of the ellipsis in characters.
34+ */
35+ private const ELLIPSIS_WIDTH = 3 ;
36+
2737 protected $ _characters = array (
2838 'corner ' => '+ ' ,
2939 'line ' => '- ' ,
@@ -264,17 +274,14 @@ protected function wrapText( $text, $width, $encoding, $is_precolorized ) {
264274
265275 // Handle truncate mode
266276 if ( 'truncate ' === $ this ->_wrapping_mode ) {
267- $ ellipsis = '... ' ;
268- $ ellipsis_width = 3 ;
269-
270- if ( $ width <= $ ellipsis_width ) {
277+ if ( $ width <= self ::ELLIPSIS_WIDTH ) {
271278 // Not enough space for ellipsis, just truncate
272279 return array ( \cli \safe_substr ( $ text , 0 , $ width , true /*is_width*/ , $ encoding ) );
273280 }
274281
275282 // Truncate and add ellipsis
276- $ truncated = \cli \safe_substr ( $ text , 0 , $ width - $ ellipsis_width , true /*is_width*/ , $ encoding );
277- return array ( $ truncated . $ ellipsis );
283+ $ truncated = \cli \safe_substr ( $ text , 0 , $ width - self :: ELLIPSIS_WIDTH , true /*is_width*/ , $ encoding );
284+ return array ( $ truncated . self :: ELLIPSIS );
278285 }
279286
280287 // Handle word-wrap mode
@@ -287,7 +294,7 @@ protected function wrapText( $text, $width, $encoding, $is_precolorized ) {
287294 $ line = $ text ;
288295
289296 // Use the new color-aware wrapping for pre-colorized content
290- if ( $ is_precolorized && Colors:: width ( $ line , true , $ encoding ) > $ width ) {
297+ if ( $ is_precolorized ) {
291298 $ wrapped_lines = Colors::wrapPreColorized ( $ line , $ width , $ encoding );
292299 } else {
293300 // For non-colorized content, use character-boundary wrapping
0 commit comments