@@ -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 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if (!isset(static::$methodArgs[$name])) { |
150 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
150 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $numArgs = \count($arguments); |
@@ -1897,9 +1897,9 @@ discard block |
||
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | $pos_end = \min( |
1900 | - UTF8::strpos($text, ' ', $l, $this->encoding), |
|
1901 | - UTF8::strpos($text, '.', $l, $this->encoding) |
|
1902 | - ) - $pos_start; |
|
1900 | + UTF8::strpos($text, ' ', $l, $this->encoding), |
|
1901 | + UTF8::strpos($text, '.', $l, $this->encoding) |
|
1902 | + ) - $pos_start; |
|
1903 | 1903 | |
1904 | 1904 | if (!$pos_end || $pos_end <= 0) { |
1905 | 1905 | $extract = $replacerForSkippedText . \ltrim( |
@@ -1939,9 +1939,9 @@ discard block |
||
1939 | 1939 | |
1940 | 1940 | if ($pos_end) { |
1941 | 1941 | $extract = \rtrim( |
1942 | - UTF8::substr($text, 0, $pos_end, $this->encoding), |
|
1943 | - $trimChars |
|
1944 | - ) . $replacerForSkippedText; |
|
1942 | + UTF8::substr($text, 0, $pos_end, $this->encoding), |
|
1943 | + $trimChars |
|
1944 | + ) . $replacerForSkippedText; |
|
1945 | 1945 | } else { |
1946 | 1946 | $extract = $text; |
1947 | 1947 | } |
@@ -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 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | // init |
66 | 66 | UTF8::checkForSupport(); |
67 | 67 | |
68 | - $this->str = (string)$str; |
|
68 | + $this->str = (string) $str; |
|
69 | 69 | |
70 | 70 | if ($encoding) { |
71 | 71 | $this->encoding = $encoding; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function __toString() |
83 | 83 | { |
84 | - return (string)$this->str; |
|
84 | + return (string) $this->str; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function append(string $string): self |
95 | 95 | { |
96 | - return static::create($this->str . $string, $this->encoding); |
|
96 | + return static::create($this->str.$string, $this->encoding); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function appendUniqueIdentifier($entropyExtra = '', bool $md5 = true): self |
122 | 122 | { |
123 | - $uniqueHelper = \mt_rand() . |
|
124 | - \session_id() . |
|
125 | - ($_SERVER['REMOTE_ADDR'] ?? '') . |
|
126 | - ($_SERVER['SERVER_ADDR'] ?? '') . |
|
123 | + $uniqueHelper = \mt_rand(). |
|
124 | + \session_id(). |
|
125 | + ($_SERVER['REMOTE_ADDR'] ?? ''). |
|
126 | + ($_SERVER['SERVER_ADDR'] ?? ''). |
|
127 | 127 | $entropyExtra; |
128 | 128 | |
129 | 129 | $uniqueString = \uniqid($uniqueHelper, true); |
130 | 130 | |
131 | 131 | if ($md5) { |
132 | - $uniqueString = \md5($uniqueString . $uniqueHelper); |
|
132 | + $uniqueString = \md5($uniqueString.$uniqueHelper); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return $this->append($uniqueString); |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | $delimiter = '/'; |
326 | 326 | } |
327 | 327 | |
328 | - $str = (string)\preg_replace( |
|
329 | - $delimiter . $pattern . $delimiter . 'u' . $options, |
|
328 | + $str = (string) \preg_replace( |
|
329 | + $delimiter.$pattern.$delimiter.'u'.$options, |
|
330 | 330 | $replacement, |
331 | 331 | $this->str |
332 | 332 | ); |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | { |
466 | 466 | $str = $this->trim(); |
467 | 467 | |
468 | - $str = (string)\preg_replace('/\B([A-Z])/u', '-\1', $str); |
|
468 | + $str = (string) \preg_replace('/\B([A-Z])/u', '-\1', $str); |
|
469 | 469 | |
470 | 470 | $str = UTF8::strtolower($str, $this->encoding); |
471 | 471 | |
472 | - $str = (string)\preg_replace('/[-_\s]+/u', $delimiter, $str); |
|
472 | + $str = (string) \preg_replace('/[-_\s]+/u', $delimiter, $str); |
|
473 | 473 | |
474 | 474 | return static::create($str, $this->encoding); |
475 | 475 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $stringy = static::create($this->str, $this->encoding); |
488 | 488 | |
489 | 489 | if (!$stringy->startsWith($substring)) { |
490 | - $stringy->str = $substring . $stringy->str; |
|
490 | + $stringy->str = $substring.$stringy->str; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $stringy; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | */ |
706 | 706 | protected function matchesPattern(string $pattern): bool |
707 | 707 | { |
708 | - if (\preg_match('/' . $pattern . '/u', $this->str)) { |
|
708 | + if (\preg_match('/'.$pattern.'/u', $this->str)) { |
|
709 | 709 | return true; |
710 | 710 | } |
711 | 711 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | $this->encoding |
871 | 871 | ); |
872 | 872 | |
873 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
873 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
874 | 874 | |
875 | 875 | return static::create($str, $this->encoding); |
876 | 876 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding); |
926 | 926 | $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding); |
927 | 927 | |
928 | - $stringy->str = $start . $substring . $end; |
|
928 | + $stringy->str = $start.$substring.$end; |
|
929 | 929 | |
930 | 930 | return $stringy; |
931 | 931 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | $quotedPattern = \preg_quote($pattern, '/'); |
952 | 952 | $replaceWildCards = \str_replace('\*', '.*', $quotedPattern); |
953 | 953 | |
954 | - return $this->matchesPattern('^' . $replaceWildCards . '\z'); |
|
954 | + return $this->matchesPattern('^'.$replaceWildCards.'\z'); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | /** |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
1175 | 1175 | |
1176 | 1176 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
1177 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
1177 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
1178 | 1178 | } else { |
1179 | 1179 | break; |
1180 | 1180 | } |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | { |
1251 | 1251 | // init |
1252 | 1252 | $length = $this->length(); |
1253 | - $offset = (int)$offset; |
|
1253 | + $offset = (int) $offset; |
|
1254 | 1254 | |
1255 | 1255 | if ($offset >= 0) { |
1256 | 1256 | return ($length > $offset); |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | public function offsetGet($offset): string |
1275 | 1275 | { |
1276 | 1276 | // init |
1277 | - $offset = (int)$offset; |
|
1277 | + $offset = (int) $offset; |
|
1278 | 1278 | $length = $this->length(); |
1279 | 1279 | |
1280 | 1280 | if ( |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | { |
1339 | 1339 | if (!\in_array($padType, ['left', 'right', 'both'], true)) { |
1340 | 1340 | throw new \InvalidArgumentException( |
1341 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
1341 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
1342 | 1342 | ); |
1343 | 1343 | } |
1344 | 1344 | |
@@ -1392,7 +1392,7 @@ discard block |
||
1392 | 1392 | $leftPadding = UTF8::substr( |
1393 | 1393 | UTF8::str_repeat( |
1394 | 1394 | $padStr, |
1395 | - (int)\ceil($left / $length) |
|
1395 | + (int) \ceil($left / $length) |
|
1396 | 1396 | ), |
1397 | 1397 | 0, |
1398 | 1398 | $left, |
@@ -1402,14 +1402,14 @@ discard block |
||
1402 | 1402 | $rightPadding = UTF8::substr( |
1403 | 1403 | UTF8::str_repeat( |
1404 | 1404 | $padStr, |
1405 | - (int)\ceil($right / $length) |
|
1405 | + (int) \ceil($right / $length) |
|
1406 | 1406 | ), |
1407 | 1407 | 0, |
1408 | 1408 | $right, |
1409 | 1409 | $stringy->encoding |
1410 | 1410 | ); |
1411 | 1411 | |
1412 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
1412 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
1413 | 1413 | |
1414 | 1414 | return $stringy; |
1415 | 1415 | } |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | { |
1442 | 1442 | $padding = $length - $this->length(); |
1443 | 1443 | |
1444 | - return $this->applyPadding((int)\floor($padding / 2), (int)\ceil($padding / 2), $padStr); |
|
1444 | + return $this->applyPadding((int) \floor($padding / 2), (int) \ceil($padding / 2), $padStr); |
|
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | /** |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | */ |
1454 | 1454 | public function prepend(string $string): self |
1455 | 1455 | { |
1456 | - return static::create($string . $this->str, $this->encoding); |
|
1456 | + return static::create($string.$this->str, $this->encoding); |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | /** |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | */ |
1561 | 1561 | public function replaceBeginning(string $search, string $replacement): self |
1562 | 1562 | { |
1563 | - $str = $this->regexReplace('^' . \preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1563 | + $str = $this->regexReplace('^'.\preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1564 | 1564 | |
1565 | 1565 | return static::create($str, $this->encoding); |
1566 | 1566 | } |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | */ |
1576 | 1576 | public function replaceEnding(string $search, string $replacement): self |
1577 | 1577 | { |
1578 | - $str = $this->regexReplace(\preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1578 | + $str = $this->regexReplace(\preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1579 | 1579 | |
1580 | 1580 | return static::create($str, $this->encoding); |
1581 | 1581 | } |
@@ -1712,11 +1712,11 @@ discard block |
||
1712 | 1712 | $lastPos = UTF8::strrpos($truncated, ' ', 0, $encoding); |
1713 | 1713 | |
1714 | 1714 | if ($lastPos !== false || $strPosSpace !== false) { |
1715 | - $truncated = UTF8::substr($truncated, 0, (int)$lastPos, $encoding); |
|
1715 | + $truncated = UTF8::substr($truncated, 0, (int) $lastPos, $encoding); |
|
1716 | 1716 | } |
1717 | 1717 | } |
1718 | 1718 | |
1719 | - $stringy->str = $truncated . $substring; |
|
1719 | + $stringy->str = $truncated.$substring; |
|
1720 | 1720 | |
1721 | 1721 | return $stringy; |
1722 | 1722 | } |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | $trimChars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&"; |
1839 | 1839 | |
1840 | 1840 | if ($length === null) { |
1841 | - $length = (int)\round($this->length() / 2, 0); |
|
1841 | + $length = (int) \round($this->length() / 2, 0); |
|
1842 | 1842 | } |
1843 | 1843 | |
1844 | 1844 | if (empty($search)) { |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | \rtrim( |
1862 | 1862 | UTF8::substr($text, 0, $pos, $this->encoding), |
1863 | 1863 | $trimChars |
1864 | - ) . $replacerForSkippedText, |
|
1864 | + ).$replacerForSkippedText, |
|
1865 | 1865 | $this->encoding |
1866 | 1866 | ); |
1867 | 1867 | } |
@@ -1875,7 +1875,7 @@ discard block |
||
1875 | 1875 | 0, |
1876 | 1876 | $this->encoding |
1877 | 1877 | ); |
1878 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1878 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1879 | 1879 | |
1880 | 1880 | if ($halfSide > 0) { |
1881 | 1881 | |
@@ -1904,7 +1904,7 @@ discard block |
||
1904 | 1904 | ) - $pos_start; |
1905 | 1905 | |
1906 | 1906 | if (!$pos_end || $pos_end <= 0) { |
1907 | - $extract = $replacerForSkippedText . \ltrim( |
|
1907 | + $extract = $replacerForSkippedText.\ltrim( |
|
1908 | 1908 | UTF8::substr( |
1909 | 1909 | $text, |
1910 | 1910 | $pos_start, |
@@ -1914,7 +1914,7 @@ discard block |
||
1914 | 1914 | $trimChars |
1915 | 1915 | ); |
1916 | 1916 | } else { |
1917 | - $extract = $replacerForSkippedText . \trim( |
|
1917 | + $extract = $replacerForSkippedText.\trim( |
|
1918 | 1918 | UTF8::substr( |
1919 | 1919 | $text, |
1920 | 1920 | $pos_start, |
@@ -1922,7 +1922,7 @@ discard block |
||
1922 | 1922 | $this->encoding |
1923 | 1923 | ), |
1924 | 1924 | $trimChars |
1925 | - ) . $replacerForSkippedText; |
|
1925 | + ).$replacerForSkippedText; |
|
1926 | 1926 | } |
1927 | 1927 | |
1928 | 1928 | } else { |
@@ -1943,7 +1943,7 @@ discard block |
||
1943 | 1943 | $extract = \rtrim( |
1944 | 1944 | UTF8::substr($text, 0, $pos_end, $this->encoding), |
1945 | 1945 | $trimChars |
1946 | - ) . $replacerForSkippedText; |
|
1946 | + ).$replacerForSkippedText; |
|
1947 | 1947 | } else { |
1948 | 1948 | $extract = $text; |
1949 | 1949 | } |
@@ -1980,7 +1980,7 @@ discard block |
||
1980 | 1980 | */ |
1981 | 1981 | public function removeHtmlBreak(string $replacement = ''): self |
1982 | 1982 | { |
1983 | - $str = (string)\preg_replace('#/\r\n|\r|\n|<br.*/?>#isU', $replacement, $this->str); |
|
1983 | + $str = (string) \preg_replace('#/\r\n|\r|\n|<br.*/?>#isU', $replacement, $this->str); |
|
1984 | 1984 | |
1985 | 1985 | return static::create($str, $this->encoding); |
1986 | 1986 | } |
@@ -2059,7 +2059,7 @@ discard block |
||
2059 | 2059 | $limit = -1; |
2060 | 2060 | } |
2061 | 2061 | |
2062 | - $array = \preg_split('/' . \preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
2062 | + $array = \preg_split('/'.\preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
2063 | 2063 | |
2064 | 2064 | if ($limit > 0 && \count($array) === $limit) { |
2065 | 2065 | \array_pop($array); |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | $apostropheRx = '(?x: [\'’] [[:lower:]]* )?'; |
2162 | 2162 | $stringy = static::create($this->trim(), $this->encoding); |
2163 | 2163 | |
2164 | - if (\preg_match('/[[:lower:]]/', (string)$stringy) === 0) { |
|
2164 | + if (\preg_match('/[[:lower:]]/', (string) $stringy) === 0) { |
|
2165 | 2165 | $stringy = $stringy->toLowerCase(); |
2166 | 2166 | } |
2167 | 2167 | |
@@ -2169,16 +2169,16 @@ discard block |
||
2169 | 2169 | $stringy->str = \preg_replace_callback( |
2170 | 2170 | '~\b (_*) (?: # 1. Leading underscore and |
2171 | 2171 | ( (?<=[ ][/\\\\]) [[:alpha:]]+ [-_[:alpha:]/\\\\]+ | # 2. file path or |
2172 | - [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostropheRx . ' ) # URL, domain, or email |
|
2172 | + [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostropheRx.' ) # URL, domain, or email |
|
2173 | 2173 | | |
2174 | - ( (?i: ' . $smallWordsRx . ' ) ' . $apostropheRx . ' ) # 3. or small word (case-insensitive) |
|
2174 | + ( (?i: ' . $smallWordsRx.' ) '.$apostropheRx.' ) # 3. or small word (case-insensitive) |
|
2175 | 2175 | | |
2176 | - ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostropheRx . ' ) # 4. or word w/o internal caps |
|
2176 | + ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostropheRx.' ) # 4. or word w/o internal caps |
|
2177 | 2177 | | |
2178 | - ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostropheRx . ' ) # 5. or some other word |
|
2178 | + ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostropheRx.' ) # 5. or some other word |
|
2179 | 2179 | ) (_*) \b # 6. With trailing underscore |
2180 | 2180 | ~ux', |
2181 | - function ($matches) { |
|
2181 | + function($matches) { |
|
2182 | 2182 | // Preserve leading underscore |
2183 | 2183 | $str = $matches[1]; |
2184 | 2184 | if ($matches[2]) { |
@@ -2207,21 +2207,21 @@ discard block |
||
2207 | 2207 | '~( \A [[:punct:]]* # start of title... |
2208 | 2208 | | [:.;?!][ ]+ # or of subsentence... |
2209 | 2209 | | [ ][\'"“‘(\[][ ]* ) # or of inserted subphrase... |
2210 | - ( ' . $smallWordsRx . ' ) \b # ...followed by small word |
|
2210 | + ( ' . $smallWordsRx.' ) \b # ...followed by small word |
|
2211 | 2211 | ~uxi', |
2212 | - function ($matches) { |
|
2213 | - return $matches[1] . static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
2212 | + function($matches) { |
|
2213 | + return $matches[1].static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
2214 | 2214 | }, |
2215 | 2215 | $stringy->str |
2216 | 2216 | ); |
2217 | 2217 | |
2218 | 2218 | // ...and end of title |
2219 | 2219 | $stringy->str = \preg_replace_callback( |
2220 | - '~\b ( ' . $smallWordsRx . ' ) # small word... |
|
2220 | + '~\b ( '.$smallWordsRx.' ) # small word... |
|
2221 | 2221 | (?= [[:punct:]]* \Z # ...at the end of the title... |
2222 | 2222 | | [\'"’”)\]] [ ] ) # ...or of an inserted subphrase? |
2223 | 2223 | ~uxi', |
2224 | - function ($matches) { |
|
2224 | + function($matches) { |
|
2225 | 2225 | return static::create($matches[1], $this->encoding)->upperCaseFirst(); |
2226 | 2226 | }, |
2227 | 2227 | $stringy->str |
@@ -2232,10 +2232,10 @@ discard block |
||
2232 | 2232 | $stringy->str = \preg_replace_callback( |
2233 | 2233 | '~\b |
2234 | 2234 | (?<! -) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (in-flight) |
2235 | - ( ' . $smallWordsRx . ' ) |
|
2235 | + ( ' . $smallWordsRx.' ) |
|
2236 | 2236 | (?= -[[:alpha:]]+) # lookahead for "-someword" |
2237 | 2237 | ~uxi', |
2238 | - function ($matches) { |
|
2238 | + function($matches) { |
|
2239 | 2239 | return static::create($matches[1], $this->encoding)->upperCaseFirst(); |
2240 | 2240 | }, |
2241 | 2241 | $stringy->str |
@@ -2246,11 +2246,11 @@ discard block |
||
2246 | 2246 | '~\b |
2247 | 2247 | (?<!…) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (stand-in) |
2248 | 2248 | ( [[:alpha:]]+- ) # $1 = first word and hyphen, should already be properly capped |
2249 | - ( ' . $smallWordsRx . ' ) # ...followed by small word |
|
2249 | + ( ' . $smallWordsRx.' ) # ...followed by small word |
|
2250 | 2250 | (?! - ) # Negative lookahead for another - |
2251 | 2251 | ~uxi', |
2252 | - function ($matches) { |
|
2253 | - return $matches[1] . static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
2252 | + function($matches) { |
|
2253 | + return $matches[1].static::create($matches[2], $this->encoding)->upperCaseFirst(); |
|
2254 | 2254 | }, |
2255 | 2255 | $stringy->str |
2256 | 2256 | ); |
@@ -2272,16 +2272,16 @@ discard block |
||
2272 | 2272 | $stringy = static::create($this->trim(), $this->encoding); |
2273 | 2273 | $encoding = $this->encoding; |
2274 | 2274 | |
2275 | - $stringy->str = (string)\preg_replace_callback( |
|
2275 | + $stringy->str = (string) \preg_replace_callback( |
|
2276 | 2276 | '/([\S]+)/u', |
2277 | - function ($match) use ($encoding, $ignore) { |
|
2277 | + function($match) use ($encoding, $ignore) { |
|
2278 | 2278 | if ($ignore && \in_array($match[0], $ignore, true)) { |
2279 | 2279 | return $match[0]; |
2280 | 2280 | } |
2281 | 2281 | |
2282 | 2282 | $stringy = new static($match[0], $encoding); |
2283 | 2283 | |
2284 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
2284 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
2285 | 2285 | }, |
2286 | 2286 | $stringy->str |
2287 | 2287 | ); |
@@ -2358,10 +2358,10 @@ discard block |
||
2358 | 2358 | } |
2359 | 2359 | |
2360 | 2360 | if (\is_numeric($this->str)) { |
2361 | - return ((int)$this->str > 0); |
|
2361 | + return ((int) $this->str > 0); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
2364 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
2365 | 2365 | } |
2366 | 2366 | |
2367 | 2367 | /** |
@@ -2371,7 +2371,7 @@ discard block |
||
2371 | 2371 | */ |
2372 | 2372 | public function toString(): string |
2373 | 2373 | { |
2374 | - return (string)$this->str; |
|
2374 | + return (string) $this->str; |
|
2375 | 2375 | } |
2376 | 2376 | |
2377 | 2377 | /** |
@@ -2494,7 +2494,7 @@ discard block |
||
2494 | 2494 | $length -= $substringLength; |
2495 | 2495 | |
2496 | 2496 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
2497 | - $stringy->str = $truncated . $substring; |
|
2497 | + $stringy->str = $truncated.$substring; |
|
2498 | 2498 | |
2499 | 2499 | return $stringy; |
2500 | 2500 | } |
@@ -2535,11 +2535,11 @@ discard block |
||
2535 | 2535 | { |
2536 | 2536 | $encoding = $this->encoding; |
2537 | 2537 | $stringy = $this->trim()->lowerCaseFirst(); |
2538 | - $stringy->str = (string)\preg_replace('/^[-_]+/', '', $stringy->str); |
|
2538 | + $stringy->str = (string) \preg_replace('/^[-_]+/', '', $stringy->str); |
|
2539 | 2539 | |
2540 | - $stringy->str = (string)\preg_replace_callback( |
|
2540 | + $stringy->str = (string) \preg_replace_callback( |
|
2541 | 2541 | '/[-_\s]+(.)?/u', |
2542 | - function ($match) use ($encoding) { |
|
2542 | + function($match) use ($encoding) { |
|
2543 | 2543 | if (isset($match[1])) { |
2544 | 2544 | return UTF8::strtoupper($match[1], $encoding); |
2545 | 2545 | } |
@@ -2549,9 +2549,9 @@ discard block |
||
2549 | 2549 | $stringy->str |
2550 | 2550 | ); |
2551 | 2551 | |
2552 | - $stringy->str = (string)\preg_replace_callback( |
|
2552 | + $stringy->str = (string) \preg_replace_callback( |
|
2553 | 2553 | '/[\d]+(.)?/u', |
2554 | - function ($match) use ($encoding) { |
|
2554 | + function($match) use ($encoding) { |
|
2555 | 2555 | return UTF8::strtoupper($match[0], $encoding); |
2556 | 2556 | }, |
2557 | 2557 | $stringy->str |
@@ -2573,27 +2573,27 @@ discard block |
||
2573 | 2573 | $str = UTF8::normalize_whitespace($str); |
2574 | 2574 | $str = \str_replace('-', '_', $str); |
2575 | 2575 | |
2576 | - $str = (string)\preg_replace_callback( |
|
2576 | + $str = (string) \preg_replace_callback( |
|
2577 | 2577 | '/([\d|A-Z])/u', |
2578 | - function ($matches) use ($encoding) { |
|
2578 | + function($matches) use ($encoding) { |
|
2579 | 2579 | $match = $matches[1]; |
2580 | - $matchInt = (int)$match; |
|
2580 | + $matchInt = (int) $match; |
|
2581 | 2581 | |
2582 | 2582 | if ("$matchInt" == $match) { |
2583 | - return '_' . $match . '_'; |
|
2583 | + return '_'.$match.'_'; |
|
2584 | 2584 | } |
2585 | 2585 | |
2586 | - return '_' . UTF8::strtolower($match, $encoding); |
|
2586 | + return '_'.UTF8::strtolower($match, $encoding); |
|
2587 | 2587 | }, |
2588 | 2588 | $str |
2589 | 2589 | ); |
2590 | 2590 | |
2591 | - $str = (string)\preg_replace( |
|
2591 | + $str = (string) \preg_replace( |
|
2592 | 2592 | [ |
2593 | 2593 | |
2594 | - '/\s+/', // convert spaces to "_" |
|
2595 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2596 | - '/_+/', // remove double "_" |
|
2594 | + '/\s+/', // convert spaces to "_" |
|
2595 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2596 | + '/_+/', // remove double "_" |
|
2597 | 2597 | ], |
2598 | 2598 | [ |
2599 | 2599 | '_', |
@@ -2619,7 +2619,7 @@ discard block |
||
2619 | 2619 | $first = UTF8::substr($this->str, 0, 1, $this->encoding); |
2620 | 2620 | $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); |
2621 | 2621 | |
2622 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
2622 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
2623 | 2623 | |
2624 | 2624 | return static::create($str, $this->encoding); |
2625 | 2625 | } |
@@ -2648,7 +2648,7 @@ discard block |
||
2648 | 2648 | */ |
2649 | 2649 | public function lineWrapAfterWord(int $limit): self |
2650 | 2650 | { |
2651 | - $strings = (array)\preg_split('/\\r\\n|\\r|\\n/', $this->str); |
|
2651 | + $strings = (array) \preg_split('/\\r\\n|\\r|\\n/', $this->str); |
|
2652 | 2652 | |
2653 | 2653 | $string = ''; |
2654 | 2654 | foreach ($strings as $value) { |
@@ -2957,7 +2957,7 @@ discard block |
||
2957 | 2957 | $restOfWord = UTF8::substr($word, 1, null, $encoding); |
2958 | 2958 | $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding); |
2959 | 2959 | |
2960 | - return static::create($firstCharacterUppercased . $restOfWord, $encoding); |
|
2960 | + return static::create($firstCharacterUppercased.$restOfWord, $encoding); |
|
2961 | 2961 | } |
2962 | 2962 | |
2963 | 2963 | /** |