@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function detect(string $subjectString) : ?ConvertHelper_EOL |
123 | 123 | { |
124 | - if(empty($subjectString)) { |
|
124 | + if (empty($subjectString)) { |
|
125 | 125 | return null; |
126 | 126 | } |
127 | 127 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | $results = array(); |
130 | 130 | $chars = self::getEOLChars(); |
131 | 131 | |
132 | - foreach($chars as $def) |
|
132 | + foreach ($chars as $def) |
|
133 | 133 | { |
134 | 134 | $amount = substr_count($subjectString, $def['char']); |
135 | 135 | |
136 | - if($amount > $max) |
|
136 | + if ($amount > $max) |
|
137 | 137 | { |
138 | 138 | $max = $amount; |
139 | 139 | $results[] = $def; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - if(empty($results)) { |
|
143 | + if (empty($results)) { |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function getEOLChars() : array |
158 | 158 | { |
159 | - if(isset(self::$eolChars)) { |
|
159 | + if (isset(self::$eolChars)) { |
|
160 | 160 | return self::$eolChars; |
161 | 161 | } |
162 | 162 |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | * @param bool $caseInsensitive |
20 | 20 | * @return ConvertHelper_StringMatch[] |
21 | 21 | */ |
22 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
|
22 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array |
|
23 | 23 | { |
24 | - if($needle === '') { |
|
24 | + if ($needle === '') { |
|
25 | 25 | return array(); |
26 | 26 | } |
27 | 27 | |
28 | 28 | $function = 'mb_strpos'; |
29 | - if($caseInsensitive) { |
|
29 | + if ($caseInsensitive) { |
|
30 | 30 | $function = 'mb_stripos'; |
31 | 31 | } |
32 | 32 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $positions = array(); |
35 | 35 | $length = mb_strlen($needle); |
36 | 36 | |
37 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
37 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
38 | 38 | { |
39 | 39 | $match = mb_substr($haystack, $pos, $length); |
40 | 40 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public static function toArray(string $string) : array |
58 | 58 | { |
59 | 59 | $result = preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY); |
60 | - if($result !== false) { |
|
60 | + if ($result !== false) { |
|
61 | 61 | return $result; |
62 | 62 | } |
63 | 63 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public static function toUtf8(string $string) : string |
112 | 112 | { |
113 | - if(!self::isASCII($string)) { |
|
113 | + if (!self::isASCII($string)) { |
|
114 | 114 | return Encoding::toUTF8($string); |
115 | 115 | } |
116 | 116 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function isASCII($string) : bool |
130 | 130 | { |
131 | - if($string === '' || $string === NULL) { |
|
131 | + if ($string === '' || $string === NULL) { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | |
135 | - if(!is_string($string)) { |
|
135 | + if (!is_string($string)) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public static function isHTML(string $string) : bool |
149 | 149 | { |
150 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
150 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | |
154 | 154 | $decoded = html_entity_decode($string); |
155 | - if($decoded !== $string) { |
|
155 | + if ($decoded !== $string) { |
|
156 | 156 | return true; |
157 | 157 | } |
158 | 158 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param int $tabSize The amount of spaces per tab. |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function tabs2spaces(string $string, int $tabSize=4) : string |
|
187 | + public static function tabs2spaces(string $string, int $tabSize = 4) : string |
|
188 | 188 | { |
189 | 189 | return str_replace("\t", str_repeat(' ', $tabSize), $string); |
190 | 190 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param int $tabSize The amount of spaces per tab in the source string. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public static function spaces2tabs(string $string, int $tabSize=4) : string |
|
199 | + public static function spaces2tabs(string $string, int $tabSize = 4) : string |
|
200 | 200 | { |
201 | 201 | return str_replace(str_repeat(' ', $tabSize), "\t", $string); |
202 | 202 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | return $text; |
274 | 274 | } |
275 | 275 | |
276 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
276 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
277 | 277 | |
278 | 278 | return $text; |
279 | 279 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | public static function explodeTrim(string $delimiter, string $string) : array |
290 | 290 | { |
291 | - if(empty($string) || empty($delimiter)) { |
|
291 | + if (empty($string) || empty($delimiter)) { |
|
292 | 292 | return array(); |
293 | 293 | } |
294 | 294 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | $tokens = array_map('trim', $tokens); |
297 | 297 | |
298 | 298 | $keep = array(); |
299 | - foreach($tokens as $token) { |
|
300 | - if($token !== '') { |
|
299 | + foreach ($tokens as $token) { |
|
300 | + if ($token !== '') { |
|
301 | 301 | $keep[] = $token; |
302 | 302 | } |
303 | 303 | } |