@@ -171,19 +171,19 @@ private function replaceStyle($match)
171
171
{
172
172
// we got "\<" escaped char
173
173
if ('\\' === $ match [1 ]) {
174
- return $ match [0 ];
174
+ return $ this -> applyCurrentStyle ( $ match [0 ]) ;
175
175
}
176
176
177
177
if ('' === $ match [3 ]) {
178
178
if ('/ ' === $ match [2 ]) {
179
179
// we got "</>" tag
180
180
$ this ->styleStack ->pop ();
181
181
182
- return $ this ->applyStyle ( $ this -> styleStack -> getCurrent (), $ match [4 ]);
182
+ return $ this ->applyCurrentStyle ( $ match [4 ]);
183
183
}
184
184
185
185
// we got "<>" tag
186
- return '<> ' .$ match [4 ];
186
+ return '<> ' .$ this -> applyCurrentStyle ( $ match [4 ]) ;
187
187
}
188
188
189
189
if (isset ($ this ->styles [strtolower ($ match [3 ])])) {
@@ -192,7 +192,7 @@ private function replaceStyle($match)
192
192
$ style = $ this ->createStyleFromString ($ match [3 ]);
193
193
194
194
if (false === $ style ) {
195
- return $ match [0 ];
195
+ return $ this -> applyCurrentStyle ( $ match [0 ]) ;
196
196
}
197
197
}
198
198
@@ -202,7 +202,7 @@ private function replaceStyle($match)
202
202
$ this ->styleStack ->push ($ style );
203
203
}
204
204
205
- return $ this ->applyStyle ( $ this -> styleStack -> getCurrent (), $ match [4 ]);
205
+ return $ this ->applyCurrentStyle ( $ match [4 ]);
206
206
}
207
207
208
208
/**
@@ -235,15 +235,14 @@ private function createStyleFromString($string)
235
235
}
236
236
237
237
/**
238
- * Applies style to text if must be applied.
238
+ * Applies current style from stack to text, if must be applied.
239
239
*
240
- * @param OutputFormatterStyleInterface $style Style to apply
241
- * @param string $text Input text
240
+ * @param string $text Input text
242
241
*
243
242
* @return string string Styled text
244
243
*/
245
- private function applyStyle ( OutputFormatterStyleInterface $ style , $ text )
244
+ private function applyCurrentStyle ( $ text )
246
245
{
247
- return $ this ->isDecorated () && strlen ($ text ) > 0 ? $ style ->apply ($ text ) : $ text ;
246
+ return $ this ->isDecorated () && strlen ($ text ) > 0 ? $ this -> styleStack -> getCurrent () ->apply ($ text ) : $ text ;
248
247
}
249
248
}
0 commit comments