66
77class OutputFormatter
88{
9+ /**
10+ * @var OutputFormat
11+ */
912 private $ oFormat ;
1013
1114 public function __construct (OutputFormat $ oFormat )
1215 {
1316 $ this ->oFormat = $ oFormat ;
1417 }
1518
19+ /**
20+ * @param string $sName
21+ * @param string|null $sType
22+ *
23+ * @return string
24+ */
1625 public function space ($ sName , $ sType = null )
1726 {
1827 $ sSpaceString = $ this ->oFormat ->get ("Space $ sName " );
@@ -28,68 +37,112 @@ public function space($sName, $sType = null)
2837 return $ this ->prepareSpace ($ sSpaceString );
2938 }
3039
40+ /**
41+ * @return string
42+ */
3143 public function spaceAfterRuleName ()
3244 {
3345 return $ this ->space ('AfterRuleName ' );
3446 }
3547
48+ /**
49+ * @return string
50+ */
3651 public function spaceBeforeRules ()
3752 {
3853 return $ this ->space ('BeforeRules ' );
3954 }
4055
56+ /**
57+ * @return string
58+ */
4159 public function spaceAfterRules ()
4260 {
4361 return $ this ->space ('AfterRules ' );
4462 }
4563
64+ /**
65+ * @return string
66+ */
4667 public function spaceBetweenRules ()
4768 {
4869 return $ this ->space ('BetweenRules ' );
4970 }
5071
72+ /**
73+ * @return string
74+ */
5175 public function spaceBeforeBlocks ()
5276 {
5377 return $ this ->space ('BeforeBlocks ' );
5478 }
5579
80+ /**
81+ * @return string
82+ */
5683 public function spaceAfterBlocks ()
5784 {
5885 return $ this ->space ('AfterBlocks ' );
5986 }
6087
88+ /**
89+ * @return string
90+ */
6191 public function spaceBetweenBlocks ()
6292 {
6393 return $ this ->space ('BetweenBlocks ' );
6494 }
6595
96+ /**
97+ * @return string
98+ */
6699 public function spaceBeforeSelectorSeparator ()
67100 {
68101 return $ this ->space ('BeforeSelectorSeparator ' );
69102 }
70103
104+ /**
105+ * @return string
106+ */
71107 public function spaceAfterSelectorSeparator ()
72108 {
73109 return $ this ->space ('AfterSelectorSeparator ' );
74110 }
75111
112+ /**
113+ * @param string $sSeparator
114+ *
115+ * @return string
116+ */
76117 public function spaceBeforeListArgumentSeparator ($ sSeparator )
77118 {
78119 return $ this ->space ('BeforeListArgumentSeparator ' , $ sSeparator );
79120 }
80121
122+ /**
123+ * @param string $sSeparator
124+ *
125+ * @return string
126+ */
81127 public function spaceAfterListArgumentSeparator ($ sSeparator )
82128 {
83129 return $ this ->space ('AfterListArgumentSeparator ' , $ sSeparator );
84130 }
85131
132+ /**
133+ * @return string
134+ */
86135 public function spaceBeforeOpeningBrace ()
87136 {
88137 return $ this ->space ('BeforeOpeningBrace ' );
89138 }
90139
91140 /**
92- * Runs the given code, either swallowing or passing exceptions, depending on the bIgnoreExceptions setting.
141+ * Runs the given code, either swallowing or passing exceptions, depending on the `bIgnoreExceptions` setting.
142+ *
143+ * @param string $cCode the name of the function to call
144+ *
145+ * @return string|null
93146 */
94147 public function safely ($ cCode )
95148 {
@@ -107,7 +160,13 @@ public function safely($cCode)
107160 }
108161
109162 /**
110- * Clone of the implode function but calls -> render with the current output format instead of `__toString()`
163+ * Clone of the `implode` function, but calls `render` with the current output format instead of `__toString()`.
164+ *
165+ * @param string $sSeparator
166+ * @param array<array-key, Renderable|string> $aValues
167+ * @param bool $bIncreaseLevel
168+ *
169+ * @return string
111170 */
112171 public function implode ($ sSeparator , array $ aValues , $ bIncreaseLevel = false )
113172 {
@@ -132,6 +191,11 @@ public function implode($sSeparator, array $aValues, $bIncreaseLevel = false)
132191 return $ sResult ;
133192 }
134193
194+ /**
195+ * @param string $sString
196+ *
197+ * @return string
198+ */
135199 public function removeLastSemicolon ($ sString )
136200 {
137201 if ($ this ->oFormat ->get ('SemicolonAfterLastRule ' )) {
@@ -147,11 +211,19 @@ public function removeLastSemicolon($sString)
147211 return implode ('; ' , $ sString );
148212 }
149213
214+ /**
215+ * @param string $sSpaceString
216+ *
217+ * @return string
218+ */
150219 private function prepareSpace ($ sSpaceString )
151220 {
152221 return str_replace ("\n" , "\n" . $ this ->indent (), $ sSpaceString );
153222 }
154223
224+ /**
225+ * @return string
226+ */
155227 private function indent ()
156228 {
157229 return str_repeat ($ this ->oFormat ->sIndentation , $ this ->oFormat ->level ());
0 commit comments