@@ -19,18 +19,54 @@ public function __construct(OutputFormat $outputFormat)
19
19
$ this ->outputFormat = $ outputFormat ;
20
20
}
21
21
22
- public function space (string $ sName , ?string $ sType = null ): string
23
- {
24
- $ sSpaceString = $ this ->outputFormat ->get ("Space $ sName " );
25
- // If $sSpaceString is an array, we have multiple values configured
26
- // depending on the type of object the space applies to
27
- if (\is_array ($ sSpaceString )) {
28
- if ($ sType !== null && isset ($ sSpaceString [$ sType ])) {
29
- $ sSpaceString = $ sSpaceString [$ sType ];
30
- } else {
31
- $ sSpaceString = \reset ($ sSpaceString );
32
- }
22
+ /**
23
+ * @param non-empty-string $sName
24
+ *
25
+ * @throws \InvalidArgumentException
26
+ */
27
+ public function space (string $ sName ): string
28
+ {
29
+ switch ($ sName ) {
30
+ case 'AfterRuleName ' :
31
+ $ sSpaceString = $ this ->outputFormat ->getSpaceAfterRuleName ();
32
+ break ;
33
+ case 'BeforeRules ' :
34
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeRules ();
35
+ break ;
36
+ case 'AfterRules ' :
37
+ $ sSpaceString = $ this ->outputFormat ->getSpaceAfterRules ();
38
+ break ;
39
+ case 'BetweenRules ' :
40
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBetweenRules ();
41
+ break ;
42
+ case 'BeforeBlocks ' :
43
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeBlocks ();
44
+ break ;
45
+ case 'AfterBlocks ' :
46
+ $ sSpaceString = $ this ->outputFormat ->getSpaceAfterBlocks ();
47
+ break ;
48
+ case 'BetweenBlocks ' :
49
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBetweenBlocks ();
50
+ break ;
51
+ case 'BeforeSelectorSeparator ' :
52
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeSelectorSeparator ();
53
+ break ;
54
+ case 'AfterSelectorSeparator ' :
55
+ $ sSpaceString = $ this ->outputFormat ->getSpaceAfterSelectorSeparator ();
56
+ break ;
57
+ case 'BeforeOpeningBrace ' :
58
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeOpeningBrace ();
59
+ break ;
60
+ case 'BeforeListArgumentSeparator ' :
61
+ $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeListArgumentSeparator ();
62
+ break ;
63
+ case 'AfterListArgumentSeparator ' :
64
+ $ sSpaceString = $ this ->outputFormat ->getSpaceAfterListArgumentSeparator ();
65
+ break ;
66
+ default :
67
+ throw new \InvalidArgumentException ("Unknown space type: $ sName " , 1740049248 );
33
68
}
69
+
34
70
return $ this ->prepareSpace ($ sSpaceString );
35
71
}
36
72
@@ -86,7 +122,7 @@ public function spaceBeforeListArgumentSeparator(string $sSeparator): string
86
122
{
87
123
$ spaceForSeparator = $ this ->outputFormat ->getSpaceBeforeListArgumentSeparators ();
88
124
89
- return $ spaceForSeparator [$ sSeparator ] ?? $ this ->space ('BeforeListArgumentSeparator ' , $ sSeparator );
125
+ return $ spaceForSeparator [$ sSeparator ] ?? $ this ->space ('BeforeListArgumentSeparator ' );
90
126
}
91
127
92
128
/**
@@ -96,7 +132,7 @@ public function spaceAfterListArgumentSeparator(string $sSeparator): string
96
132
{
97
133
$ spaceForSeparator = $ this ->outputFormat ->getSpaceAfterListArgumentSeparators ();
98
134
99
- return $ spaceForSeparator [$ sSeparator ] ?? $ this ->space ('AfterListArgumentSeparator ' , $ sSeparator );
135
+ return $ spaceForSeparator [$ sSeparator ] ?? $ this ->space ('AfterListArgumentSeparator ' );
100
136
}
101
137
102
138
public function spaceBeforeOpeningBrace (): string
@@ -109,7 +145,7 @@ public function spaceBeforeOpeningBrace(): string
109
145
*/
110
146
public function safely (callable $ cCode ): ?string
111
147
{
112
- if ($ this ->outputFormat ->get ( ' IgnoreExceptions ' )) {
148
+ if ($ this ->outputFormat ->getIgnoreExceptions ( )) {
113
149
// If output exceptions are ignored, run the code with exception guards
114
150
try {
115
151
return $ cCode ();
@@ -152,7 +188,7 @@ public function implode(string $sSeparator, array $aValues, bool $bIncreaseLevel
152
188
153
189
public function removeLastSemicolon (string $ sString ): string
154
190
{
155
- if ($ this ->outputFormat ->get ( ' SemicolonAfterLastRule ' )) {
191
+ if ($ this ->outputFormat ->getSemicolonAfterLastRule ( )) {
156
192
return $ sString ;
157
193
}
158
194
$ sString = \explode ('; ' , $ sString );
@@ -167,7 +203,7 @@ public function removeLastSemicolon(string $sString): string
167
203
168
204
public function comments (Commentable $ oCommentable ): string
169
205
{
170
- if (!$ this ->outputFormat ->bRenderComments ) {
206
+ if (!$ this ->outputFormat ->getRenderComments () ) {
171
207
return '' ;
172
208
}
173
209
0 commit comments