@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Stringy; |
| 6 | 6 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $this->str = (string)$str; |
|
| 65 | + $this->str = (string) $str; |
|
| 66 | 66 | |
| 67 | 67 | if ($encoding) { |
| 68 | 68 | $this->encoding = UTF8::normalize_encoding($encoding); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function __toString() |
| 80 | 80 | { |
| 81 | - return (string)$this->str; |
|
| 81 | + return (string) $this->str; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function append(string $string): self |
| 92 | 92 | { |
| 93 | - return static::create($this->str . $string, $this->encoding); |
|
| 93 | + return static::create($this->str.$string, $this->encoding); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -117,16 +117,16 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function appendUniqueIdentifier($entropyExtra = '', bool $md5 = true): self |
| 119 | 119 | { |
| 120 | - $uniqueHelper = \mt_rand() . |
|
| 121 | - \session_id() . |
|
| 122 | - ($_SERVER['REMOTE_ADDR'] ?? '') . |
|
| 123 | - ($_SERVER['SERVER_ADDR'] ?? '') . |
|
| 120 | + $uniqueHelper = \mt_rand(). |
|
| 121 | + \session_id(). |
|
| 122 | + ($_SERVER['REMOTE_ADDR'] ?? ''). |
|
| 123 | + ($_SERVER['SERVER_ADDR'] ?? ''). |
|
| 124 | 124 | $entropyExtra; |
| 125 | 125 | |
| 126 | 126 | $uniqueString = \uniqid($uniqueHelper, true); |
| 127 | 127 | |
| 128 | 128 | if ($md5) { |
| 129 | - $uniqueString = \md5($uniqueString . $uniqueHelper); |
|
| 129 | + $uniqueString = \md5($uniqueString.$uniqueHelper); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return $this->append($uniqueString); |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | $delimiter = '/'; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $str = (string)\preg_replace( |
|
| 332 | - $delimiter . $pattern . $delimiter . 'u' . $options, |
|
| 331 | + $str = (string) \preg_replace( |
|
| 332 | + $delimiter.$pattern.$delimiter.'u'.$options, |
|
| 333 | 333 | $replacement, |
| 334 | 334 | $this->str |
| 335 | 335 | ); |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | { |
| 469 | 469 | $str = $this->trim(); |
| 470 | 470 | |
| 471 | - $str = (string)\preg_replace('/\B([A-Z])/u', '-\1', $str); |
|
| 471 | + $str = (string) \preg_replace('/\B([A-Z])/u', '-\1', $str); |
|
| 472 | 472 | |
| 473 | 473 | $str = UTF8::strtolower($str, $this->encoding); |
| 474 | 474 | |
| 475 | - $str = (string)\preg_replace('/[-_\s]+/u', $delimiter, $str); |
|
| 475 | + $str = (string) \preg_replace('/[-_\s]+/u', $delimiter, $str); |
|
| 476 | 476 | |
| 477 | 477 | return static::create($str, $this->encoding); |
| 478 | 478 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $stringy = static::create($this->str, $this->encoding); |
| 491 | 491 | |
| 492 | 492 | if (!$stringy->startsWith($substring)) { |
| 493 | - $stringy->str = $substring . $stringy->str; |
|
| 493 | + $stringy->str = $substring.$stringy->str; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $stringy; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | */ |
| 709 | 709 | protected function matchesPattern(string $pattern): bool |
| 710 | 710 | { |
| 711 | - if (\preg_match('/' . $pattern . '/u', $this->str)) { |
|
| 711 | + if (\preg_match('/'.$pattern.'/u', $this->str)) { |
|
| 712 | 712 | return true; |
| 713 | 713 | } |
| 714 | 714 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | $this->encoding |
| 874 | 874 | ); |
| 875 | 875 | |
| 876 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
| 876 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
| 877 | 877 | |
| 878 | 878 | return static::create($str, $this->encoding); |
| 879 | 879 | } |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding); |
| 929 | 929 | $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding); |
| 930 | 930 | |
| 931 | - $stringy->str = $start . $substring . $end; |
|
| 931 | + $stringy->str = $start.$substring.$end; |
|
| 932 | 932 | |
| 933 | 933 | return $stringy; |
| 934 | 934 | } |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $quotedPattern = \preg_quote($pattern, '/'); |
| 955 | 955 | $replaceWildCards = \str_replace('\*', '.*', $quotedPattern); |
| 956 | 956 | |
| 957 | - return $this->matchesPattern('^' . $replaceWildCards . '\z'); |
|
| 957 | + return $this->matchesPattern('^'.$replaceWildCards.'\z'); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
| 1178 | 1178 | |
| 1179 | 1179 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
| 1180 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
| 1180 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
| 1181 | 1181 | } else { |
| 1182 | 1182 | break; |
| 1183 | 1183 | } |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | { |
| 1254 | 1254 | // init |
| 1255 | 1255 | $length = $this->length(); |
| 1256 | - $offset = (int)$offset; |
|
| 1256 | + $offset = (int) $offset; |
|
| 1257 | 1257 | |
| 1258 | 1258 | if ($offset >= 0) { |
| 1259 | 1259 | return ($length > $offset); |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | public function offsetGet($offset): string |
| 1278 | 1278 | { |
| 1279 | 1279 | // init |
| 1280 | - $offset = (int)$offset; |
|
| 1280 | + $offset = (int) $offset; |
|
| 1281 | 1281 | $length = $this->length(); |
| 1282 | 1282 | |
| 1283 | 1283 | if ( |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | { |
| 1342 | 1342 | if (!\in_array($padType, ['left', 'right', 'both'], true)) { |
| 1343 | 1343 | throw new \InvalidArgumentException( |
| 1344 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
| 1344 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
| 1345 | 1345 | ); |
| 1346 | 1346 | } |
| 1347 | 1347 | |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | $leftPadding = UTF8::substr( |
| 1396 | 1396 | UTF8::str_repeat( |
| 1397 | 1397 | $padStr, |
| 1398 | - (int)\ceil($left / $length) |
|
| 1398 | + (int) \ceil($left / $length) |
|
| 1399 | 1399 | ), |
| 1400 | 1400 | 0, |
| 1401 | 1401 | $left, |
@@ -1405,14 +1405,14 @@ discard block |
||
| 1405 | 1405 | $rightPadding = UTF8::substr( |
| 1406 | 1406 | UTF8::str_repeat( |
| 1407 | 1407 | $padStr, |
| 1408 | - (int)\ceil($right / $length) |
|
| 1408 | + (int) \ceil($right / $length) |
|
| 1409 | 1409 | ), |
| 1410 | 1410 | 0, |
| 1411 | 1411 | $right, |
| 1412 | 1412 | $stringy->encoding |
| 1413 | 1413 | ); |
| 1414 | 1414 | |
| 1415 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
| 1415 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
| 1416 | 1416 | |
| 1417 | 1417 | return $stringy; |
| 1418 | 1418 | } |
@@ -1444,7 +1444,7 @@ discard block |
||
| 1444 | 1444 | { |
| 1445 | 1445 | $padding = $length - $this->length(); |
| 1446 | 1446 | |
| 1447 | - return $this->applyPadding((int)\floor($padding / 2), (int)\ceil($padding / 2), $padStr); |
|
| 1447 | + return $this->applyPadding((int) \floor($padding / 2), (int) \ceil($padding / 2), $padStr); |
|
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | /** |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | */ |
| 1457 | 1457 | public function prepend(string $string): self |
| 1458 | 1458 | { |
| 1459 | - return static::create($string . $this->str, $this->encoding); |
|
| 1459 | + return static::create($string.$this->str, $this->encoding); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /** |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | */ |
| 1564 | 1564 | public function replaceBeginning(string $search, string $replacement): self |
| 1565 | 1565 | { |
| 1566 | - $str = $this->regexReplace('^' . \preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1566 | + $str = $this->regexReplace('^'.\preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1567 | 1567 | |
| 1568 | 1568 | return static::create($str, $this->encoding); |
| 1569 | 1569 | } |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | */ |
| 1579 | 1579 | public function replaceEnding(string $search, string $replacement): self |
| 1580 | 1580 | { |
| 1581 | - $str = $this->regexReplace(\preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1581 | + $str = $this->regexReplace(\preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1582 | 1582 | |
| 1583 | 1583 | return static::create($str, $this->encoding); |
| 1584 | 1584 | } |
@@ -1715,11 +1715,11 @@ discard block |
||
| 1715 | 1715 | $lastPos = UTF8::strrpos($truncated, ' ', 0, $encoding); |
| 1716 | 1716 | |
| 1717 | 1717 | if ($lastPos !== false || $strPosSpace !== false) { |
| 1718 | - $truncated = UTF8::substr($truncated, 0, (int)$lastPos, $encoding); |
|
| 1718 | + $truncated = UTF8::substr($truncated, 0, (int) $lastPos, $encoding); |
|
| 1719 | 1719 | } |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | - $stringy->str = $truncated . $substring; |
|
| 1722 | + $stringy->str = $truncated.$substring; |
|
| 1723 | 1723 | |
| 1724 | 1724 | return $stringy; |
| 1725 | 1725 | } |
@@ -1841,7 +1841,7 @@ discard block |
||
| 1841 | 1841 | $trimChars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&"; |
| 1842 | 1842 | |
| 1843 | 1843 | if ($length === null) { |
| 1844 | - $length = (int)\round($this->length() / 2, 0); |
|
| 1844 | + $length = (int) \round($this->length() / 2, 0); |
|
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | if (empty($search)) { |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | \rtrim( |
| 1865 | 1865 | UTF8::substr($text, 0, $pos, $this->encoding), |
| 1866 | 1866 | $trimChars |
| 1867 | - ) . $replacerForSkippedText, |
|
| 1867 | + ).$replacerForSkippedText, |
|
| 1868 | 1868 | $this->encoding |
| 1869 | 1869 | ); |
| 1870 | 1870 | } |
@@ -1878,7 +1878,7 @@ discard block |
||
| 1878 | 1878 | 0, |
| 1879 | 1879 | $this->encoding |
| 1880 | 1880 | ); |
| 1881 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
| 1881 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
| 1882 | 1882 | |
| 1883 | 1883 | if ($halfSide > 0) { |
| 1884 | 1884 | |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | ) - $pos_start; |
| 1908 | 1908 | |
| 1909 | 1909 | if (!$pos_end || $pos_end <= 0) { |
| 1910 | - $extract = $replacerForSkippedText . \ltrim( |
|
| 1910 | + $extract = $replacerForSkippedText.\ltrim( |
|
| 1911 | 1911 | UTF8::substr( |
| 1912 | 1912 | $text, |
| 1913 | 1913 | $pos_start, |
@@ -1917,7 +1917,7 @@ discard block |
||
| 1917 | 1917 | $trimChars |
| 1918 | 1918 | ); |
| 1919 | 1919 | } else { |
| 1920 | - $extract = $replacerForSkippedText . \trim( |
|
| 1920 | + $extract = $replacerForSkippedText.\trim( |
|
| 1921 | 1921 | UTF8::substr( |
| 1922 | 1922 | $text, |
| 1923 | 1923 | $pos_start, |
@@ -1925,7 +1925,7 @@ discard block |
||
| 1925 | 1925 | $this->encoding |
| 1926 | 1926 | ), |
| 1927 | 1927 | $trimChars |
| 1928 | - ) . $replacerForSkippedText; |
|
| 1928 | + ).$replacerForSkippedText; |
|
| 1929 | 1929 | } |
| 1930 | 1930 | |
| 1931 | 1931 | } else { |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | $extract = \rtrim( |
| 1947 | 1947 | UTF8::substr($text, 0, $pos_end, $this->encoding), |
| 1948 | 1948 | $trimChars |
| 1949 | - ) . $replacerForSkippedText; |
|
| 1949 | + ).$replacerForSkippedText; |
|
| 1950 | 1950 | } else { |
| 1951 | 1951 | $extract = $text; |
| 1952 | 1952 | } |
@@ -1983,7 +1983,7 @@ discard block |
||
| 1983 | 1983 | */ |
| 1984 | 1984 | public function removeHtmlBreak(string $replacement = ''): self |
| 1985 | 1985 | { |
| 1986 | - $str = (string)\preg_replace('#/\r\n|\r|\n|<br.*/?>#isU', $replacement, $this->str); |
|
| 1986 | + $str = (string) \preg_replace('#/\r\n|\r|\n|<br.*/?>#isU', $replacement, $this->str); |
|
| 1987 | 1987 | |
| 1988 | 1988 | return static::create($str, $this->encoding); |
| 1989 | 1989 | } |
@@ -2062,7 +2062,7 @@ discard block |
||
| 2062 | 2062 | $limit = -1; |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | - $array = \preg_split('/' . \preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
| 2065 | + $array = \preg_split('/'.\preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
| 2066 | 2066 | |
| 2067 | 2067 | if ($limit > 0 && \count($array) === $limit) { |
| 2068 | 2068 | \array_pop($array); |
@@ -2164,7 +2164,7 @@ discard block |
||
| 2164 | 2164 | $apostropheRx = '(?x: [\'’] [[:lower:]]* )?'; |
| 2165 | 2165 | $stringy = static::create($this->trim(), $this->encoding); |
| 2166 | 2166 | |
| 2167 | - if (\preg_match('/[[:lower:]]/', (string)$stringy) === 0) { |
|
| 2167 | + if (\preg_match('/[[:lower:]]/', (string) $stringy) === 0) { |
|
| 2168 | 2168 | $stringy = $stringy->toLowerCase(); |
| 2169 | 2169 | } |
| 2170 | 2170 | |
@@ -2172,16 +2172,16 @@ discard block |
||
| 2172 | 2172 | $stringy->str = \preg_replace_callback( |
| 2173 | 2173 | '~\b (_*) (?: # 1. Leading underscore and |
| 2174 | 2174 | ( (?<=[ ][/\\\\]) [[:alpha:]]+ [-_[:alpha:]/\\\\]+ | # 2. file path or |
| 2175 | - [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostropheRx . ' ) # URL, domain, or email |
|
| 2175 | + [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostropheRx.' ) # URL, domain, or email |
|
| 2176 | 2176 | | |
| 2177 | - ( (?i: ' . $smallWordsRx . ' ) ' . $apostropheRx . ' ) # 3. or small word (case-insensitive) |
|
| 2177 | + ( (?i: ' . $smallWordsRx.' ) '.$apostropheRx.' ) # 3. or small word (case-insensitive) |
|
| 2178 | 2178 | | |
| 2179 | - ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostropheRx . ' ) # 4. or word w/o internal caps |
|
| 2179 | + ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostropheRx.' ) # 4. or word w/o internal caps |
|
| 2180 | 2180 | | |
| 2181 | - ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostropheRx . ' ) # 5. or some other word |
|
| 2181 | + ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostropheRx.' ) # 5. or some other word |
|
| 2182 | 2182 | ) (_*) \b # 6. With trailing underscore |
| 2183 | 2183 | ~ux', |
| 2184 | - function ($matches) { |
|
| 2184 | + function($matches) { |
|
| 2185 | 2185 | // Preserve leading underscore |
| 2186 | 2186 | $str = $matches[1]; |
| 2187 | 2187 | if ($matches[2]) { |
@@ -2210,21 +2210,21 @@ discard block |
||
| 2210 | 2210 | '~( \A [[:punct:]]* # start of title... |
| 2211 | 2211 | | [:.;?!][ ]+ # or of subsentence... |
| 2212 | 2212 | | [ ][\'"“‘(\[][ ]* ) # or of inserted subphrase... |
| 2213 | - ( ' . $smallWordsRx . ' ) \b # ...followed by small word |
|
| 2213 | + ( ' . $smallWordsRx.' ) \b # ...followed by small word |
|
| 2214 | 2214 | ~uxi', |
| 2215 | - function ($matches) { |
|
| 2216 | - return $matches[1] . static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
| 2215 | + function($matches) { |
|
| 2216 | + return $matches[1].static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
| 2217 | 2217 | }, |
| 2218 | 2218 | $stringy->str |
| 2219 | 2219 | ); |
| 2220 | 2220 | |
| 2221 | 2221 | // ...and end of title |
| 2222 | 2222 | $stringy->str = \preg_replace_callback( |
| 2223 | - '~\b ( ' . $smallWordsRx . ' ) # small word... |
|
| 2223 | + '~\b ( '.$smallWordsRx.' ) # small word... |
|
| 2224 | 2224 | (?= [[:punct:]]* \Z # ...at the end of the title... |
| 2225 | 2225 | | [\'"’”)\]] [ ] ) # ...or of an inserted subphrase? |
| 2226 | 2226 | ~uxi', |
| 2227 | - function ($matches) { |
|
| 2227 | + function($matches) { |
|
| 2228 | 2228 | return static::create($matches[1], $this->encoding)->upperCaseFirst(); |
| 2229 | 2229 | }, |
| 2230 | 2230 | $stringy->str |
@@ -2235,10 +2235,10 @@ discard block |
||
| 2235 | 2235 | $stringy->str = \preg_replace_callback( |
| 2236 | 2236 | '~\b |
| 2237 | 2237 | (?<! -) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (in-flight) |
| 2238 | - ( ' . $smallWordsRx . ' ) |
|
| 2238 | + ( ' . $smallWordsRx.' ) |
|
| 2239 | 2239 | (?= -[[:alpha:]]+) # lookahead for "-someword" |
| 2240 | 2240 | ~uxi', |
| 2241 | - function ($matches) { |
|
| 2241 | + function($matches) { |
|
| 2242 | 2242 | return static::create($matches[1], $this->encoding)->upperCaseFirst(); |
| 2243 | 2243 | }, |
| 2244 | 2244 | $stringy->str |
@@ -2249,11 +2249,11 @@ discard block |
||
| 2249 | 2249 | '~\b |
| 2250 | 2250 | (?<!…) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (stand-in) |
| 2251 | 2251 | ( [[:alpha:]]+- ) # $1 = first word and hyphen, should already be properly capped |
| 2252 | - ( ' . $smallWordsRx . ' ) # ...followed by small word |
|
| 2252 | + ( ' . $smallWordsRx.' ) # ...followed by small word |
|
| 2253 | 2253 | (?! - ) # Negative lookahead for another - |
| 2254 | 2254 | ~uxi', |
| 2255 | - function ($matches) { |
|
| 2256 | - return $matches[1] . static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
| 2255 | + function($matches) { |
|
| 2256 | + return $matches[1].static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
| 2257 | 2257 | }, |
| 2258 | 2258 | $stringy->str |
| 2259 | 2259 | ); |
@@ -2275,16 +2275,16 @@ discard block |
||
| 2275 | 2275 | $stringy = static::create($this->trim(), $this->encoding); |
| 2276 | 2276 | $encoding = $this->encoding; |
| 2277 | 2277 | |
| 2278 | - $stringy->str = (string)\preg_replace_callback( |
|
| 2278 | + $stringy->str = (string) \preg_replace_callback( |
|
| 2279 | 2279 | '/([\S]+)/u', |
| 2280 | - function ($match) use ($encoding, $ignore) { |
|
| 2280 | + function($match) use ($encoding, $ignore) { |
|
| 2281 | 2281 | if ($ignore && \in_array($match[0], $ignore, true)) { |
| 2282 | 2282 | return $match[0]; |
| 2283 | 2283 | } |
| 2284 | 2284 | |
| 2285 | 2285 | $stringy = new static($match[0], $encoding); |
| 2286 | 2286 | |
| 2287 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
| 2287 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
| 2288 | 2288 | }, |
| 2289 | 2289 | $stringy->str |
| 2290 | 2290 | ); |
@@ -2361,10 +2361,10 @@ discard block |
||
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | if (\is_numeric($this->str)) { |
| 2364 | - return ((int)$this->str > 0); |
|
| 2364 | + return ((int) $this->str > 0); |
|
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
| 2367 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
| 2368 | 2368 | } |
| 2369 | 2369 | |
| 2370 | 2370 | /** |
@@ -2374,7 +2374,7 @@ discard block |
||
| 2374 | 2374 | */ |
| 2375 | 2375 | public function toString(): string |
| 2376 | 2376 | { |
| 2377 | - return (string)$this->str; |
|
| 2377 | + return (string) $this->str; |
|
| 2378 | 2378 | } |
| 2379 | 2379 | |
| 2380 | 2380 | /** |
@@ -2497,7 +2497,7 @@ discard block |
||
| 2497 | 2497 | $length -= $substringLength; |
| 2498 | 2498 | |
| 2499 | 2499 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
| 2500 | - $stringy->str = $truncated . $substring; |
|
| 2500 | + $stringy->str = $truncated.$substring; |
|
| 2501 | 2501 | |
| 2502 | 2502 | return $stringy; |
| 2503 | 2503 | } |
@@ -2538,11 +2538,11 @@ discard block |
||
| 2538 | 2538 | { |
| 2539 | 2539 | $encoding = $this->encoding; |
| 2540 | 2540 | $stringy = $this->trim()->lowerCaseFirst(); |
| 2541 | - $stringy->str = (string)\preg_replace('/^[-_]+/', '', $stringy->str); |
|
| 2541 | + $stringy->str = (string) \preg_replace('/^[-_]+/', '', $stringy->str); |
|
| 2542 | 2542 | |
| 2543 | - $stringy->str = (string)\preg_replace_callback( |
|
| 2543 | + $stringy->str = (string) \preg_replace_callback( |
|
| 2544 | 2544 | '/[-_\s]+(.)?/u', |
| 2545 | - function ($match) use ($encoding) { |
|
| 2545 | + function($match) use ($encoding) { |
|
| 2546 | 2546 | if (isset($match[1])) { |
| 2547 | 2547 | return UTF8::strtoupper($match[1], $encoding); |
| 2548 | 2548 | } |
@@ -2552,9 +2552,9 @@ discard block |
||
| 2552 | 2552 | $stringy->str |
| 2553 | 2553 | ); |
| 2554 | 2554 | |
| 2555 | - $stringy->str = (string)\preg_replace_callback( |
|
| 2555 | + $stringy->str = (string) \preg_replace_callback( |
|
| 2556 | 2556 | '/[\d]+(.)?/u', |
| 2557 | - function ($match) use ($encoding) { |
|
| 2557 | + function($match) use ($encoding) { |
|
| 2558 | 2558 | return UTF8::strtoupper($match[0], $encoding); |
| 2559 | 2559 | }, |
| 2560 | 2560 | $stringy->str |
@@ -2576,27 +2576,27 @@ discard block |
||
| 2576 | 2576 | $str = UTF8::normalize_whitespace($str); |
| 2577 | 2577 | $str = \str_replace('-', '_', $str); |
| 2578 | 2578 | |
| 2579 | - $str = (string)\preg_replace_callback( |
|
| 2579 | + $str = (string) \preg_replace_callback( |
|
| 2580 | 2580 | '/([\d|A-Z])/u', |
| 2581 | - function ($matches) use ($encoding) { |
|
| 2581 | + function($matches) use ($encoding) { |
|
| 2582 | 2582 | $match = $matches[1]; |
| 2583 | - $matchInt = (int)$match; |
|
| 2583 | + $matchInt = (int) $match; |
|
| 2584 | 2584 | |
| 2585 | 2585 | if ("$matchInt" == $match) { |
| 2586 | - return '_' . $match . '_'; |
|
| 2586 | + return '_'.$match.'_'; |
|
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | - return '_' . UTF8::strtolower($match, $encoding); |
|
| 2589 | + return '_'.UTF8::strtolower($match, $encoding); |
|
| 2590 | 2590 | }, |
| 2591 | 2591 | $str |
| 2592 | 2592 | ); |
| 2593 | 2593 | |
| 2594 | - $str = (string)\preg_replace( |
|
| 2594 | + $str = (string) \preg_replace( |
|
| 2595 | 2595 | [ |
| 2596 | 2596 | |
| 2597 | - '/\s+/', // convert spaces to "_" |
|
| 2598 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2599 | - '/_+/', // remove double "_" |
|
| 2597 | + '/\s+/', // convert spaces to "_" |
|
| 2598 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2599 | + '/_+/', // remove double "_" |
|
| 2600 | 2600 | ], |
| 2601 | 2601 | [ |
| 2602 | 2602 | '_', |
@@ -2622,7 +2622,7 @@ discard block |
||
| 2622 | 2622 | $first = UTF8::substr($this->str, 0, 1, $this->encoding); |
| 2623 | 2623 | $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); |
| 2624 | 2624 | |
| 2625 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
| 2625 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
| 2626 | 2626 | |
| 2627 | 2627 | return static::create($str, $this->encoding); |
| 2628 | 2628 | } |
@@ -2651,7 +2651,7 @@ discard block |
||
| 2651 | 2651 | */ |
| 2652 | 2652 | public function lineWrapAfterWord(int $limit): self |
| 2653 | 2653 | { |
| 2654 | - $strings = (array)\preg_split('/\\r\\n|\\r|\\n/', $this->str); |
|
| 2654 | + $strings = (array) \preg_split('/\\r\\n|\\r|\\n/', $this->str); |
|
| 2655 | 2655 | |
| 2656 | 2656 | $string = ''; |
| 2657 | 2657 | foreach ($strings as $value) { |
@@ -2960,7 +2960,7 @@ discard block |
||
| 2960 | 2960 | $restOfWord = UTF8::substr($word, 1, null, $encoding); |
| 2961 | 2961 | $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding); |
| 2962 | 2962 | |
| 2963 | - return static::create($firstCharacterUppercased . $restOfWord, $encoding); |
|
| 2963 | + return static::create($firstCharacterUppercased.$restOfWord, $encoding); |
|
| 2964 | 2964 | } |
| 2965 | 2965 | |
| 2966 | 2966 | /** |