@@ -90,17 +90,17 @@ public static function str_increment(string $string): string
90
90
throw new \ValueError ('str_increment(): Argument #1 ($string) cannot be empty ' );
91
91
}
92
92
93
- if (!\ preg_match (" /^[a-zA-Z0-9]+$/ " , $ string )) {
93
+ if (!preg_match (' /^[a-zA-Z0-9]+$/ ' , $ string )) {
94
94
throw new \ValueError ('str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' );
95
95
}
96
96
97
- if (\ is_numeric ($ string )) {
97
+ if (is_numeric ($ string )) {
98
98
$ offset = stripos ($ string , 'e ' );
99
- if ($ offset !== false ) {
99
+ if (false !== $ offset ) {
100
100
$ char = $ string [$ offset ];
101
- $ char ++ ;
101
+ ++ $ char ;
102
102
$ string [$ offset ] = $ char ;
103
- $ string ++ ;
103
+ ++ $ string ;
104
104
105
105
switch ($ string [$ offset ]) {
106
106
case 'f ' :
@@ -130,64 +130,64 @@ public static function str_decrement(string $string): string
130
130
throw new \ValueError ('str_decrement(): Argument #1 ($string) cannot be empty ' );
131
131
}
132
132
133
- if (!\ preg_match (" /^[a-zA-Z0-9]+$/ " , $ string )) {
133
+ if (!preg_match (' /^[a-zA-Z0-9]+$/ ' , $ string )) {
134
134
throw new \ValueError ('str_decrement(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' );
135
135
}
136
136
137
- if (\ preg_match ('/\A(?:0[aA0]?|[aA])\z/ ' , $ string )) {
137
+ if (preg_match ('/\A(?:0[aA0]?|[aA])\z/ ' , $ string )) {
138
138
throw new \ValueError (sprintf ('str_decrement(): Argument #1 ($string) "%s" is out of decrement range ' , $ string ));
139
139
}
140
140
141
141
if (!\in_array (substr ($ string , -1 ), ['A ' , 'a ' , '0 ' ], true )) {
142
- return join ('' , array_slice (str_split ($ string ), 0 , -1 )) . chr (ord (substr ($ string , -1 )) - 1 );
142
+ return implode ('' , \ array_slice (str_split ($ string ), 0 , -1 )). \ chr (\ ord (substr ($ string , -1 )) - 1 );
143
143
}
144
144
145
145
$ carry = '' ;
146
146
$ decremented = '' ;
147
147
148
- for ($ i = strlen ($ string ) - 1 ; $ i >= 0 ; $ i -- ) {
148
+ for ($ i = \ strlen ($ string ) - 1 ; $ i >= 0 ; -- $ i ) {
149
149
$ char = $ string [$ i ];
150
150
151
151
switch ($ char ) {
152
152
case 'A ' :
153
153
if ('' !== $ carry ) {
154
- $ decremented = $ carry . $ decremented ;
154
+ $ decremented = $ carry. $ decremented ;
155
155
$ carry = '' ;
156
156
}
157
157
$ carry = 'Z ' ;
158
158
159
159
break ;
160
160
case 'a ' :
161
161
if ('' !== $ carry ) {
162
- $ decremented = $ carry . $ decremented ;
162
+ $ decremented = $ carry. $ decremented ;
163
163
$ carry = '' ;
164
164
}
165
165
$ carry = 'z ' ;
166
166
167
167
break ;
168
168
case '0 ' :
169
169
if ('' !== $ carry ) {
170
- $ decremented = $ carry . $ decremented ;
170
+ $ decremented = $ carry. $ decremented ;
171
171
$ carry = '' ;
172
172
}
173
173
$ carry = '9 ' ;
174
174
175
175
break ;
176
176
case '1 ' :
177
177
if ('' !== $ carry ) {
178
- $ decremented = $ carry . $ decremented ;
178
+ $ decremented = $ carry. $ decremented ;
179
179
$ carry = '' ;
180
180
}
181
181
182
182
break ;
183
183
default :
184
184
if ('' !== $ carry ) {
185
- $ decremented = $ carry . $ decremented ;
185
+ $ decremented = $ carry. $ decremented ;
186
186
$ carry = '' ;
187
187
}
188
188
189
189
if (!\in_array ($ char , ['A ' , 'a ' , '0 ' ], true )) {
190
- $ decremented = chr (ord ($ char ) - 1 ) . $ decremented ;
190
+ $ decremented = \ chr (\ ord ($ char ) - 1 ). $ decremented ;
191
191
}
192
192
}
193
193
}
0 commit comments