1212 */
1313class MenuMenuItem implements MenuItemInterface
1414{
15- private $ text = '' ;
15+ /**
16+ * @var string
17+ */
18+ private $ text ;
1619
17- private $ showItemExtra = false ;
20+ /**
21+ * @var CliMenu
22+ */
23+ private $ subMenu ;
1824
19- private $ disabled = false ;
25+ /**
26+ * @var bool
27+ */
28+ private $ showItemExtra ;
2029
2130 /**
22- * @var SelectableStyle;
31+ * @var bool
2332 */
24- private $ style ;
25-
33+ private $ disabled ;
34+
2635 /**
27- * @var CliMenu
36+ * @var SelectableStyle;
2837 */
29- private $ subMenu ;
38+ private $ style ;
3039
3140 public function __construct (
3241 string $ text ,
3342 CliMenu $ subMenu ,
3443 bool $ disabled = false
3544 ) {
36- $ this ->text = $ text ;
37- $ this ->subMenu = $ subMenu ;
45+ $ this ->text = $ text ;
46+ $ this ->subMenu = $ subMenu ;
3847 $ this ->disabled = $ disabled ;
3948
4049 $ this ->style = new SelectableStyle ();
@@ -79,41 +88,46 @@ public function getRows(MenuStyle $style, bool $selected = false) : array
7988 }
8089
8190 /**
82- * Execute the items callable if required
91+ * Return the raw string of text
8392 */
84- public function getSelectAction () : ? callable
93+ public function getText () : string
8594 {
86- return function (CliMenu $ menu ) {
87- $ this ->showSubMenu ($ menu );
88- };
95+ return $ this ->text ;
8996 }
9097
91- public function getStyle () : SelectableStyle
98+ /**
99+ * Set the raw string of text
100+ */
101+ public function setText (string $ text ) : void
92102 {
93- return $ this ->style ;
103+ $ this ->text = $ text ;
94104 }
95105
96- public function setStyle (SelectableStyle $ style ) : self
106+ /**
107+ * Execute the items callable if required
108+ */
109+ public function getSelectAction () : ?callable
97110 {
98- $ this -> style = $ style ;
99-
100- return $ this ;
111+ return function ( CliMenu $ menu ) {
112+ $ this -> showSubMenu ( $ menu );
113+ } ;
101114 }
102115
103116 /**
104- * Return the raw string of text
117+ * Returns the sub menu
105118 */
106- public function getText () : string
119+ public function getSubMenu () : CliMenu
107120 {
108- return $ this ->text ;
121+ return $ this ->subMenu ;
109122 }
110123
111124 /**
112- * Set the raw string of text
125+ * Display the sub menu
113126 */
114- public function setText ( string $ text ) : void
127+ public function showSubMenu ( CliMenu $ parentMenu ) : void
115128 {
116- $ this ->text = $ text ;
129+ $ parentMenu ->closeThis ();
130+ $ this ->subMenu ->open ();
117131 }
118132
119133 /**
@@ -124,11 +138,6 @@ public function canSelect() : bool
124138 return !$ this ->disabled ;
125139 }
126140
127- public function showsItemExtra () : bool
128- {
129- return $ this ->showItemExtra ;
130- }
131-
132141 /**
133142 * Enable showing item extra
134143 */
@@ -137,6 +146,14 @@ public function showItemExtra() : void
137146 $ this ->showItemExtra = true ;
138147 }
139148
149+ /**
150+ * Whether or not we are showing item extra
151+ */
152+ public function showsItemExtra () : bool
153+ {
154+ return $ this ->showItemExtra ;
155+ }
156+
140157 /**
141158 * Disable showing item extra
142159 */
@@ -145,20 +162,15 @@ public function hideItemExtra() : void
145162 $ this ->showItemExtra = false ;
146163 }
147164
148- /**
149- * Returns the sub menu
150- */
151- public function getSubMenu () : CliMenu
165+ public function getStyle () : SelectableStyle
152166 {
153- return $ this ->subMenu ;
167+ return $ this ->style ;
154168 }
155169
156- /**
157- * Display the sub menu
158- */
159- public function showSubMenu (CliMenu $ parentMenu ) : void
170+ public function setStyle (SelectableStyle $ style ) : self
160171 {
161- $ parentMenu ->closeThis ();
162- $ this ->subMenu ->open ();
172+ $ this ->style = $ style ;
173+
174+ return $ this ;
163175 }
164176}
0 commit comments