File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -27,17 +27,23 @@ class AsciiArtItem implements MenuItemInterface
27
27
*/
28
28
private $ position ;
29
29
30
+ /**
31
+ * @var string
32
+ */
33
+ private $ alternateText ;
34
+
30
35
/**
31
36
* @var int
32
37
*/
33
38
private $ artLength ;
34
39
35
- public function __construct (string $ text , string $ position = self ::POSITION_CENTER )
40
+ public function __construct (string $ text , string $ position = self ::POSITION_CENTER , string $ alt = '' )
36
41
{
37
42
Assertion::inArray ($ position , [self ::POSITION_CENTER , self ::POSITION_RIGHT , self ::POSITION_LEFT ]);
38
43
39
44
$ this ->text = $ text ;
40
45
$ this ->position = $ position ;
46
+ $ this ->alternateText = $ alt ;
41
47
$ this ->artLength = max (array_map ('mb_strlen ' , explode ("\n" , $ text )));
42
48
}
43
49
@@ -46,6 +52,11 @@ public function __construct(string $text, string $position = self::POSITION_CENT
46
52
*/
47
53
public function getRows (MenuStyle $ style , bool $ selected = false ) : array
48
54
{
55
+ if ($ this ->artLength > $ style ->getContentWidth ()) {
56
+ $ alternate = new StaticItem ($ this ->alternateText );
57
+ return $ alternate ->getRows ($ style , false );
58
+ }
59
+
49
60
return array_map (function ($ row ) use ($ style ) {
50
61
$ length = mb_strlen ($ row );
51
62
You can’t perform that action at this time.
0 commit comments