@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // init |
| 69 | 69 | UTF8::checkForSupport(); |
| 70 | 70 | |
| 71 | - $this->str = (string)$str; |
|
| 71 | + $this->str = (string) $str; |
|
| 72 | 72 | |
| 73 | 73 | if ($encoding) { |
| 74 | 74 | $this->encoding = $encoding; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function __toString() |
| 93 | 93 | { |
| 94 | - return (string)$this->str; |
|
| 94 | + return (string) $this->str; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function append($string) |
| 105 | 105 | { |
| 106 | - return static::create($this->str . $string, $this->encoding); |
|
| 106 | + return static::create($this->str.$string, $this->encoding); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function appendUniqueIdentifier($extraPrefix = '') |
| 131 | 131 | { |
| 132 | - $prefix = mt_rand() . |
|
| 133 | - session_id() . |
|
| 134 | - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') . |
|
| 135 | - (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '') . |
|
| 132 | + $prefix = mt_rand(). |
|
| 133 | + session_id(). |
|
| 134 | + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''). |
|
| 135 | + (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''). |
|
| 136 | 136 | $extraPrefix; |
| 137 | 137 | |
| 138 | - return $this->append(md5(uniqid($prefix, true) . $prefix)); |
|
| 138 | + return $this->append(md5(uniqid($prefix, true).$prefix)); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | // init |
| 152 | 152 | $i = 0; |
| 153 | - $length = (int)$length; |
|
| 153 | + $length = (int) $length; |
|
| 154 | 154 | $str = $this->str; |
| 155 | 155 | $maxlength = UTF8::strlen($possibleChars, $this->encoding); |
| 156 | 156 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function indexOf($needle, $offset = 0) |
| 228 | 228 | { |
| 229 | - return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 229 | + return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function indexOfIgnoreCase($needle, $offset = 0) |
| 243 | 243 | { |
| 244 | - return UTF8::stripos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 244 | + return UTF8::stripos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $str = preg_replace( |
| 326 | - '/' . $pattern . '/u' . $options, |
|
| 326 | + '/'.$pattern.'/u'.$options, |
|
| 327 | 327 | $replacement, |
| 328 | 328 | $this->str |
| 329 | 329 | ); |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | $stringy = static::create($this->str, $this->encoding); |
| 485 | 485 | |
| 486 | 486 | if (!$stringy->startsWith($substring)) { |
| 487 | - $stringy->str = $substring . $stringy->str; |
|
| 487 | + $stringy->str = $substring.$stringy->str; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | return $stringy; |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $endOfStr = UTF8::strtolower($endOfStr, $this->encoding); |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - return (string)$substring === $endOfStr; |
|
| 586 | + return (string) $substring === $endOfStr; |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | protected function matchesPattern($pattern) |
| 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 | |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | $this->encoding |
| 780 | 780 | ); |
| 781 | 781 | |
| 782 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
| 782 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
| 783 | 783 | |
| 784 | 784 | return static::create($str, $this->encoding); |
| 785 | 785 | } |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | */ |
| 798 | 798 | public function indexOfLast($needle, $offset = 0) |
| 799 | 799 | { |
| 800 | - return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 800 | + return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | /** |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | */ |
| 814 | 814 | public function indexOfLastIgnoreCase($needle, $offset = 0) |
| 815 | 815 | { |
| 816 | - return UTF8::strripos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 816 | + return UTF8::strripos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding); |
| 835 | 835 | $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding); |
| 836 | 836 | |
| 837 | - $stringy->str = $start . $substring . $end; |
|
| 837 | + $stringy->str = $start.$substring.$end; |
|
| 838 | 838 | |
| 839 | 839 | return $stringy; |
| 840 | 840 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $quotedPattern = preg_quote($pattern, '/'); |
| 861 | 861 | $replaceWildCards = str_replace('\*', '.*', $quotedPattern); |
| 862 | 862 | |
| 863 | - return $this->matchesPattern('^' . $replaceWildCards . '\z'); |
|
| 863 | + return $this->matchesPattern('^'.$replaceWildCards.'\z'); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
| 1098 | 1098 | |
| 1099 | 1099 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
| 1100 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
| 1100 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
| 1101 | 1101 | } else { |
| 1102 | 1102 | break; |
| 1103 | 1103 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | { |
| 1173 | 1173 | // init |
| 1174 | 1174 | $length = $this->length(); |
| 1175 | - $offset = (int)$offset; |
|
| 1175 | + $offset = (int) $offset; |
|
| 1176 | 1176 | |
| 1177 | 1177 | if ($offset >= 0) { |
| 1178 | 1178 | return ($length > $offset); |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | public function offsetGet($offset) |
| 1197 | 1197 | { |
| 1198 | 1198 | // init |
| 1199 | - $offset = (int)$offset; |
|
| 1199 | + $offset = (int) $offset; |
|
| 1200 | 1200 | $length = $this->length(); |
| 1201 | 1201 | |
| 1202 | 1202 | if ( |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | { |
| 1258 | 1258 | if (!in_array($padType, array('left', 'right', 'both'), true)) { |
| 1259 | 1259 | throw new \InvalidArgumentException( |
| 1260 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
| 1260 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
| 1261 | 1261 | ); |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | $stringy->encoding |
| 1329 | 1329 | ); |
| 1330 | 1330 | |
| 1331 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
| 1331 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
| 1332 | 1332 | |
| 1333 | 1333 | return $stringy; |
| 1334 | 1334 | } |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | */ |
| 1373 | 1373 | public function prepend($string) |
| 1374 | 1374 | { |
| 1375 | - return static::create($string . $this->str, $this->encoding); |
|
| 1375 | + return static::create($string.$this->str, $this->encoding); |
|
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | /** |
@@ -1479,7 +1479,7 @@ discard block |
||
| 1479 | 1479 | */ |
| 1480 | 1480 | public function replaceBeginning($search, $replacement) |
| 1481 | 1481 | { |
| 1482 | - $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1482 | + $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1483 | 1483 | |
| 1484 | 1484 | return static::create($str, $this->encoding); |
| 1485 | 1485 | } |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | */ |
| 1495 | 1495 | public function replaceEnding($search, $replacement) |
| 1496 | 1496 | { |
| 1497 | - $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1497 | + $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1498 | 1498 | |
| 1499 | 1499 | return static::create($str, $this->encoding); |
| 1500 | 1500 | } |
@@ -1635,7 +1635,7 @@ discard block |
||
| 1635 | 1635 | } |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | - $stringy->str = $truncated . $substring; |
|
| 1638 | + $stringy->str = $truncated.$substring; |
|
| 1639 | 1639 | |
| 1640 | 1640 | return $stringy; |
| 1641 | 1641 | } |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | $trimChars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&"; |
| 1758 | 1758 | |
| 1759 | 1759 | if ($length === null) { |
| 1760 | - $length = (int)round($this->length() / 2, 0); |
|
| 1760 | + $length = (int) round($this->length() / 2, 0); |
|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | if (empty($search)) { |
@@ -1771,7 +1771,7 @@ discard block |
||
| 1771 | 1771 | rtrim( |
| 1772 | 1772 | UTF8::substr($text, 0, $pos, $this->encoding), |
| 1773 | 1773 | $trimChars |
| 1774 | - ) . $ellipsis, |
|
| 1774 | + ).$ellipsis, |
|
| 1775 | 1775 | $this->encoding |
| 1776 | 1776 | ); |
| 1777 | 1777 | } |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | null, |
| 1786 | 1786 | $this->encoding |
| 1787 | 1787 | ); |
| 1788 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
| 1788 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
| 1789 | 1789 | |
| 1790 | 1790 | if ($halfSide > 0) { |
| 1791 | 1791 | |
@@ -1814,7 +1814,7 @@ discard block |
||
| 1814 | 1814 | ) - $pos_start; |
| 1815 | 1815 | |
| 1816 | 1816 | if (!$pos_end || $pos_end <= 0) { |
| 1817 | - $extract = $ellipsis . ltrim( |
|
| 1817 | + $extract = $ellipsis.ltrim( |
|
| 1818 | 1818 | UTF8::substr( |
| 1819 | 1819 | $text, |
| 1820 | 1820 | $pos_start, |
@@ -1824,7 +1824,7 @@ discard block |
||
| 1824 | 1824 | $trimChars |
| 1825 | 1825 | ); |
| 1826 | 1826 | } else { |
| 1827 | - $extract = $ellipsis . trim( |
|
| 1827 | + $extract = $ellipsis.trim( |
|
| 1828 | 1828 | UTF8::substr( |
| 1829 | 1829 | $text, |
| 1830 | 1830 | $pos_start, |
@@ -1832,7 +1832,7 @@ discard block |
||
| 1832 | 1832 | $this->encoding |
| 1833 | 1833 | ), |
| 1834 | 1834 | $trimChars |
| 1835 | - ) . $ellipsis; |
|
| 1835 | + ).$ellipsis; |
|
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | } else { |
@@ -1853,7 +1853,7 @@ discard block |
||
| 1853 | 1853 | $extract = rtrim( |
| 1854 | 1854 | UTF8::substr($text, 0, $pos_end, $this->encoding), |
| 1855 | 1855 | $trimChars |
| 1856 | - ) . $ellipsis; |
|
| 1856 | + ).$ellipsis; |
|
| 1857 | 1857 | } else { |
| 1858 | 1858 | $extract = $text; |
| 1859 | 1859 | } |
@@ -1967,7 +1967,7 @@ discard block |
||
| 1967 | 1967 | $limit = -1; |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
| 1970 | + $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
| 1971 | 1971 | |
| 1972 | 1972 | if ($limit > 0 && count($array) === $limit) { |
| 1973 | 1973 | array_pop($array); |
@@ -2041,14 +2041,14 @@ discard block |
||
| 2041 | 2041 | |
| 2042 | 2042 | $stringy->str = preg_replace_callback( |
| 2043 | 2043 | '/([\S]+)/u', |
| 2044 | - function ($match) use ($encoding, $ignore) { |
|
| 2044 | + function($match) use ($encoding, $ignore) { |
|
| 2045 | 2045 | if ($ignore && in_array($match[0], $ignore, true)) { |
| 2046 | 2046 | return $match[0]; |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | 2049 | $stringy = new Stringy($match[0], $encoding); |
| 2050 | 2050 | |
| 2051 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
| 2051 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
| 2052 | 2052 | }, |
| 2053 | 2053 | $stringy->str |
| 2054 | 2054 | ); |
@@ -2125,10 +2125,10 @@ discard block |
||
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | if (is_numeric($this->str)) { |
| 2128 | - return ((int)$this->str > 0); |
|
| 2128 | + return ((int) $this->str > 0); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
| 2131 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | 2134 | /** |
@@ -2138,7 +2138,7 @@ discard block |
||
| 2138 | 2138 | */ |
| 2139 | 2139 | public function toString() |
| 2140 | 2140 | { |
| 2141 | - return (string)$this->str; |
|
| 2141 | + return (string) $this->str; |
|
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | 2144 | /** |
@@ -2262,7 +2262,7 @@ discard block |
||
| 2262 | 2262 | $length -= $substringLength; |
| 2263 | 2263 | |
| 2264 | 2264 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
| 2265 | - $stringy->str = $truncated . $substring; |
|
| 2265 | + $stringy->str = $truncated.$substring; |
|
| 2266 | 2266 | |
| 2267 | 2267 | return $stringy; |
| 2268 | 2268 | } |
@@ -2307,7 +2307,7 @@ discard block |
||
| 2307 | 2307 | |
| 2308 | 2308 | $stringy->str = preg_replace_callback( |
| 2309 | 2309 | '/[-_\s]+(.)?/u', |
| 2310 | - function ($match) use ($encoding) { |
|
| 2310 | + function($match) use ($encoding) { |
|
| 2311 | 2311 | if (isset($match[1])) { |
| 2312 | 2312 | return UTF8::strtoupper($match[1], $encoding); |
| 2313 | 2313 | } |
@@ -2319,7 +2319,7 @@ discard block |
||
| 2319 | 2319 | |
| 2320 | 2320 | $stringy->str = preg_replace_callback( |
| 2321 | 2321 | '/[\d]+(.)?/u', |
| 2322 | - function ($match) use ($encoding) { |
|
| 2322 | + function($match) use ($encoding) { |
|
| 2323 | 2323 | return UTF8::strtoupper($match[0], $encoding); |
| 2324 | 2324 | }, |
| 2325 | 2325 | $stringy->str |
@@ -2343,15 +2343,15 @@ discard block |
||
| 2343 | 2343 | |
| 2344 | 2344 | $str = preg_replace_callback( |
| 2345 | 2345 | '/([\d|A-Z])/u', |
| 2346 | - function ($matches) use ($encoding) { |
|
| 2346 | + function($matches) use ($encoding) { |
|
| 2347 | 2347 | $match = $matches[1]; |
| 2348 | - $matchInt = (int)$match; |
|
| 2348 | + $matchInt = (int) $match; |
|
| 2349 | 2349 | |
| 2350 | 2350 | if ("$matchInt" == $match) { |
| 2351 | - return '_' . $match . '_'; |
|
| 2351 | + return '_'.$match.'_'; |
|
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | - return '_' . UTF8::strtolower($match, $encoding); |
|
| 2354 | + return '_'.UTF8::strtolower($match, $encoding); |
|
| 2355 | 2355 | }, |
| 2356 | 2356 | $str |
| 2357 | 2357 | ); |
@@ -2359,9 +2359,9 @@ discard block |
||
| 2359 | 2359 | $str = preg_replace( |
| 2360 | 2360 | array( |
| 2361 | 2361 | |
| 2362 | - '/\s+/', // convert spaces to "_" |
|
| 2363 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2364 | - '/_+/', // remove double "_" |
|
| 2362 | + '/\s+/', // convert spaces to "_" |
|
| 2363 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2364 | + '/_+/', // remove double "_" |
|
| 2365 | 2365 | ), |
| 2366 | 2366 | array( |
| 2367 | 2367 | '_', |
@@ -2387,7 +2387,7 @@ discard block |
||
| 2387 | 2387 | $first = UTF8::substr($this->str, 0, 1, $this->encoding); |
| 2388 | 2388 | $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); |
| 2389 | 2389 | |
| 2390 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
| 2390 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
| 2391 | 2391 | |
| 2392 | 2392 | return static::create($str, $this->encoding); |
| 2393 | 2393 | } |
@@ -2725,7 +2725,7 @@ discard block |
||
| 2725 | 2725 | $restOfWord = UTF8::substr($word, 1, null, $encoding); |
| 2726 | 2726 | $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding); |
| 2727 | 2727 | |
| 2728 | - return new static($firstCharacterUppercased . $restOfWord, $encoding); |
|
| 2728 | + return new static($firstCharacterUppercased.$restOfWord, $encoding); |
|
| 2729 | 2729 | } |
| 2730 | 2730 | |
| 2731 | 2731 | /** |
@@ -2739,7 +2739,7 @@ discard block |
||
| 2739 | 2739 | protected function capitalizePersonalNameByDelimiter($names, $delimiter) |
| 2740 | 2740 | { |
| 2741 | 2741 | // init |
| 2742 | - $names = explode((string)$delimiter, (string)$names); |
|
| 2742 | + $names = explode((string) $delimiter, (string) $names); |
|
| 2743 | 2743 | $encoding = $this->encoding; |
| 2744 | 2744 | |
| 2745 | 2745 | $specialCases = array( |