@@ -136,7 +136,7 @@ |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (!isset(static::$methodArgs[$name])) { |
| 139 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
| 139 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $numArgs = count($arguments); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // init |
| 62 | 62 | UTF8::checkForSupport(); |
| 63 | - $this->str = (string)$str; |
|
| 63 | + $this->str = (string) $str; |
|
| 64 | 64 | |
| 65 | 65 | if ($encoding) { |
| 66 | 66 | $this->encoding = $encoding; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function append($string) |
| 97 | 97 | { |
| 98 | - return static::create($this->str . $string, $this->encoding); |
|
| 98 | + return static::create($this->str.$string, $this->encoding); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function appendUniqueIdentifier($extraPrefix = '') |
| 123 | 123 | { |
| 124 | - $prefix = mt_rand() . |
|
| 125 | - session_id() . |
|
| 126 | - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') . |
|
| 127 | - (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '') . |
|
| 124 | + $prefix = mt_rand(). |
|
| 125 | + session_id(). |
|
| 126 | + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''). |
|
| 127 | + (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''). |
|
| 128 | 128 | $extraPrefix; |
| 129 | 129 | |
| 130 | - return $this->append(md5(uniqid($prefix, true) . $prefix)); |
|
| 130 | + return $this->append(md5(uniqid($prefix, true).$prefix)); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | // init |
| 144 | 144 | $i = 0; |
| 145 | - $length = (int)$length; |
|
| 145 | + $length = (int) $length; |
|
| 146 | 146 | $str = $this->str; |
| 147 | 147 | $maxlength = UTF8::strlen($possibleChars); |
| 148 | 148 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function indexOf($needle, $offset = 0) |
| 220 | 220 | { |
| 221 | - return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 221 | + return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | $str = preg_replace( |
| 303 | - '/' . $pattern . '/u' . $options, |
|
| 303 | + '/'.$pattern.'/u'.$options, |
|
| 304 | 304 | $replacement, |
| 305 | 305 | $this->str |
| 306 | 306 | ); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $stringy = static::create($this->str, $this->encoding); |
| 462 | 462 | |
| 463 | 463 | if (!$stringy->startsWith($substring)) { |
| 464 | - $stringy->str = $substring . $stringy->str; |
|
| 464 | + $stringy->str = $substring.$stringy->str; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | return $stringy; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $startOfStr = UTF8::strtolower($startOfStr, $this->encoding); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - return (string)$substring === $startOfStr; |
|
| 493 | + return (string) $substring === $startOfStr; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $endOfStr = UTF8::strtolower($endOfStr, $this->encoding); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - return (string)$substring === $endOfStr; |
|
| 542 | + return (string) $substring === $endOfStr; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | private function matchesPattern($pattern) |
| 637 | 637 | { |
| 638 | - if (preg_match('/' . $pattern . '/u', $this->str)) { |
|
| 638 | + if (preg_match('/'.$pattern.'/u', $this->str)) { |
|
| 639 | 639 | return true; |
| 640 | 640 | } else { |
| 641 | 641 | return false; |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | $this->encoding |
| 710 | 710 | ); |
| 711 | 711 | |
| 712 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
| 712 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
| 713 | 713 | |
| 714 | 714 | return static::create($str, $this->encoding); |
| 715 | 715 | } |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | */ |
| 728 | 728 | public function indexOfLast($needle, $offset = 0) |
| 729 | 729 | { |
| 730 | - return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
| 730 | + return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | $stringy->encoding |
| 752 | 752 | ); |
| 753 | 753 | |
| 754 | - $stringy->str = $start . $substring . $end; |
|
| 754 | + $stringy->str = $start.$substring.$end; |
|
| 755 | 755 | |
| 756 | 756 | return $stringy; |
| 757 | 757 | } |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
| 963 | 963 | |
| 964 | 964 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
| 965 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
| 965 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
| 966 | 966 | } else { |
| 967 | 967 | break; |
| 968 | 968 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | { |
| 1038 | 1038 | // init |
| 1039 | 1039 | $length = $this->length(); |
| 1040 | - $offset = (int)$offset; |
|
| 1040 | + $offset = (int) $offset; |
|
| 1041 | 1041 | |
| 1042 | 1042 | if ($offset >= 0) { |
| 1043 | 1043 | return ($length > $offset); |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | public function offsetGet($offset) |
| 1062 | 1062 | { |
| 1063 | 1063 | // init |
| 1064 | - $offset = (int)$offset; |
|
| 1064 | + $offset = (int) $offset; |
|
| 1065 | 1065 | $length = $this->length(); |
| 1066 | 1066 | |
| 1067 | 1067 | if ( |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | { |
| 1123 | 1123 | if (!in_array($padType, array('left', 'right', 'both'), true)) { |
| 1124 | 1124 | throw new \InvalidArgumentException( |
| 1125 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
| 1125 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
| 1126 | 1126 | ); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
@@ -1193,7 +1193,7 @@ discard block |
||
| 1193 | 1193 | $stringy->encoding |
| 1194 | 1194 | ); |
| 1195 | 1195 | |
| 1196 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
| 1196 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
| 1197 | 1197 | |
| 1198 | 1198 | return $stringy; |
| 1199 | 1199 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | */ |
| 1238 | 1238 | public function prepend($string) |
| 1239 | 1239 | { |
| 1240 | - return static::create($string . $this->str, $this->encoding); |
|
| 1240 | + return static::create($string.$this->str, $this->encoding); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | */ |
| 1345 | 1345 | public function replaceBeginning($search, $replacement) |
| 1346 | 1346 | { |
| 1347 | - $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1347 | + $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1348 | 1348 | |
| 1349 | 1349 | return static::create($str, $this->encoding); |
| 1350 | 1350 | } |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | */ |
| 1360 | 1360 | public function replaceEnding($search, $replacement) |
| 1361 | 1361 | { |
| 1362 | - $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1362 | + $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1363 | 1363 | |
| 1364 | 1364 | return static::create($str, $this->encoding); |
| 1365 | 1365 | } |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | $truncated = UTF8::substr($truncated, 0, $lastPos, $encoding); |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | - $stringy->str = $truncated . $substring; |
|
| 1411 | + $stringy->str = $truncated.$substring; |
|
| 1412 | 1412 | |
| 1413 | 1413 | return $stringy; |
| 1414 | 1414 | } |
@@ -1525,7 +1525,7 @@ discard block |
||
| 1525 | 1525 | $pos = min(UTF8::strpos($text, ' ', $end), UTF8::strpos($text, '.', $end)); |
| 1526 | 1526 | |
| 1527 | 1527 | if ($pos) { |
| 1528 | - return static::create(rtrim(UTF8::substr($text, 0, $pos), $trimChars) . $ellipsis, $this->encoding); |
|
| 1528 | + return static::create(rtrim(UTF8::substr($text, 0, $pos), $trimChars).$ellipsis, $this->encoding); |
|
| 1529 | 1529 | } else { |
| 1530 | 1530 | return static::create($text, $this->encoding); |
| 1531 | 1531 | } |
@@ -1533,7 +1533,7 @@ discard block |
||
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | $wordPos = UTF8::strpos(UTF8::strtolower($text), UTF8::strtolower($search), null); |
| 1536 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search) / 2); |
|
| 1536 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search) / 2); |
|
| 1537 | 1537 | |
| 1538 | 1538 | if ($halfSide > 0) { |
| 1539 | 1539 | |
@@ -1559,9 +1559,9 @@ discard block |
||
| 1559 | 1559 | $pos_end = min(UTF8::strpos($text, ' ', $l), UTF8::strpos($text, '.', $l)) - $pos_start; |
| 1560 | 1560 | |
| 1561 | 1561 | if (!$pos_end || $pos_end <= 0) { |
| 1562 | - $extract = $ellipsis . ltrim(UTF8::substr($text, $pos_start, UTF8::strlen($text)), $trimChars); |
|
| 1562 | + $extract = $ellipsis.ltrim(UTF8::substr($text, $pos_start, UTF8::strlen($text)), $trimChars); |
|
| 1563 | 1563 | } else { |
| 1564 | - $extract = $ellipsis . trim(UTF8::substr($text, $pos_start, $pos_end), $trimChars) . $ellipsis; |
|
| 1564 | + $extract = $ellipsis.trim(UTF8::substr($text, $pos_start, $pos_end), $trimChars).$ellipsis; |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | 1567 | } else { |
@@ -1576,7 +1576,7 @@ discard block |
||
| 1576 | 1576 | $pos_end = min(UTF8::strpos($text, ' ', $l), UTF8::strpos($text, '.', $l)); |
| 1577 | 1577 | |
| 1578 | 1578 | if ($pos_end) { |
| 1579 | - $extract = rtrim(UTF8::substr($text, 0, $pos_end), $trimChars) . $ellipsis; |
|
| 1579 | + $extract = rtrim(UTF8::substr($text, 0, $pos_end), $trimChars).$ellipsis; |
|
| 1580 | 1580 | } else { |
| 1581 | 1581 | $extract = $text; |
| 1582 | 1582 | } |
@@ -1690,7 +1690,7 @@ discard block |
||
| 1690 | 1690 | $limit = -1; |
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | - $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
| 1693 | + $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
| 1694 | 1694 | |
| 1695 | 1695 | if ($limit > 0 && count($array) === $limit) { |
| 1696 | 1696 | array_pop($array); |
@@ -1764,13 +1764,13 @@ discard block |
||
| 1764 | 1764 | |
| 1765 | 1765 | $stringy->str = preg_replace_callback( |
| 1766 | 1766 | '/([\S]+)/u', |
| 1767 | - function ($match) use ($encoding, $ignore) { |
|
| 1767 | + function($match) use ($encoding, $ignore) { |
|
| 1768 | 1768 | if ($ignore && in_array($match[0], $ignore, true)) { |
| 1769 | 1769 | return $match[0]; |
| 1770 | 1770 | } else { |
| 1771 | 1771 | $stringy = new Stringy($match[0], $encoding); |
| 1772 | 1772 | |
| 1773 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
| 1773 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | }, |
| 1776 | 1776 | $stringy->str |
@@ -1844,9 +1844,9 @@ discard block |
||
| 1844 | 1844 | if (array_key_exists($key, $map)) { |
| 1845 | 1845 | return $map[$key]; |
| 1846 | 1846 | } elseif (is_numeric($this->str)) { |
| 1847 | - return ((int)$this->str > 0); |
|
| 1847 | + return ((int) $this->str > 0); |
|
| 1848 | 1848 | } else { |
| 1849 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
| 1849 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
| 1850 | 1850 | } |
| 1851 | 1851 | } |
| 1852 | 1852 | |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | */ |
| 1858 | 1858 | public function toString() |
| 1859 | 1859 | { |
| 1860 | - return (string)$this->str; |
|
| 1860 | + return (string) $this->str; |
|
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | 1863 | /** |
@@ -1981,7 +1981,7 @@ discard block |
||
| 1981 | 1981 | $length -= $substringLength; |
| 1982 | 1982 | |
| 1983 | 1983 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
| 1984 | - $stringy->str = $truncated . $substring; |
|
| 1984 | + $stringy->str = $truncated.$substring; |
|
| 1985 | 1985 | |
| 1986 | 1986 | return $stringy; |
| 1987 | 1987 | } |
@@ -2026,7 +2026,7 @@ discard block |
||
| 2026 | 2026 | |
| 2027 | 2027 | $stringy->str = preg_replace_callback( |
| 2028 | 2028 | '/[-_\s]+(.)?/u', |
| 2029 | - function ($match) use ($encoding) { |
|
| 2029 | + function($match) use ($encoding) { |
|
| 2030 | 2030 | if (isset($match[1])) { |
| 2031 | 2031 | return UTF8::strtoupper($match[1], $encoding); |
| 2032 | 2032 | } else { |
@@ -2038,7 +2038,7 @@ discard block |
||
| 2038 | 2038 | |
| 2039 | 2039 | $stringy->str = preg_replace_callback( |
| 2040 | 2040 | '/[\d]+(.)?/u', |
| 2041 | - function ($match) use ($encoding) { |
|
| 2041 | + function($match) use ($encoding) { |
|
| 2042 | 2042 | return UTF8::strtoupper($match[0], $encoding); |
| 2043 | 2043 | }, |
| 2044 | 2044 | $stringy->str |
@@ -2061,14 +2061,14 @@ discard block |
||
| 2061 | 2061 | |
| 2062 | 2062 | $str = preg_replace_callback( |
| 2063 | 2063 | '/([\d|A-Z])/u', |
| 2064 | - function ($matches) { |
|
| 2064 | + function($matches) { |
|
| 2065 | 2065 | $match = $matches[1]; |
| 2066 | - $matchInt = (int)$match; |
|
| 2066 | + $matchInt = (int) $match; |
|
| 2067 | 2067 | |
| 2068 | 2068 | if ("$matchInt" == $match) { |
| 2069 | - return '_' . $match . '_'; |
|
| 2069 | + return '_'.$match.'_'; |
|
| 2070 | 2070 | } else { |
| 2071 | - return '_' . UTF8::strtolower($match); |
|
| 2071 | + return '_'.UTF8::strtolower($match); |
|
| 2072 | 2072 | } |
| 2073 | 2073 | }, |
| 2074 | 2074 | $str |
@@ -2077,9 +2077,9 @@ discard block |
||
| 2077 | 2077 | $str = preg_replace( |
| 2078 | 2078 | array( |
| 2079 | 2079 | |
| 2080 | - '/\s+/', // convert spaces to "_" |
|
| 2081 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2082 | - '/_+/', // remove double "_" |
|
| 2080 | + '/\s+/', // convert spaces to "_" |
|
| 2081 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 2082 | + '/_+/', // remove double "_" |
|
| 2083 | 2083 | ), |
| 2084 | 2084 | array( |
| 2085 | 2085 | '_', |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | $this->encoding |
| 2109 | 2109 | ); |
| 2110 | 2110 | |
| 2111 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
| 2111 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
| 2112 | 2112 | |
| 2113 | 2113 | return static::create($str, $this->encoding); |
| 2114 | 2114 | } |