@@ -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 | } |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
| 953 | 953 | |
| 954 | 954 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
| 955 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
| 955 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
| 956 | 956 | } else { |
| 957 | 957 | break; |
| 958 | 958 | } |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | { |
| 1028 | 1028 | // init |
| 1029 | 1029 | $length = $this->length(); |
| 1030 | - $offset = (int)$offset; |
|
| 1030 | + $offset = (int) $offset; |
|
| 1031 | 1031 | |
| 1032 | 1032 | if ($offset >= 0) { |
| 1033 | 1033 | return ($length > $offset); |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | public function offsetGet($offset) |
| 1052 | 1052 | { |
| 1053 | 1053 | // init |
| 1054 | - $offset = (int)$offset; |
|
| 1054 | + $offset = (int) $offset; |
|
| 1055 | 1055 | $length = $this->length(); |
| 1056 | 1056 | |
| 1057 | 1057 | if ( |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | { |
| 1113 | 1113 | if (!in_array($padType, array('left', 'right', 'both'), true)) { |
| 1114 | 1114 | throw new \InvalidArgumentException( |
| 1115 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
| 1115 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
| 1116 | 1116 | ); |
| 1117 | 1117 | } |
| 1118 | 1118 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $stringy->encoding |
| 1184 | 1184 | ); |
| 1185 | 1185 | |
| 1186 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
| 1186 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
| 1187 | 1187 | |
| 1188 | 1188 | return $stringy; |
| 1189 | 1189 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | */ |
| 1228 | 1228 | public function prepend($string) |
| 1229 | 1229 | { |
| 1230 | - return static::create($string . $this->str, $this->encoding); |
|
| 1230 | + return static::create($string.$this->str, $this->encoding); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | */ |
| 1335 | 1335 | public function replaceBeginning($search, $replacement) |
| 1336 | 1336 | { |
| 1337 | - $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1337 | + $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1338 | 1338 | |
| 1339 | 1339 | return static::create($str, $this->encoding); |
| 1340 | 1340 | } |
@@ -1349,7 +1349,7 @@ discard block |
||
| 1349 | 1349 | */ |
| 1350 | 1350 | public function replaceEnding($search, $replacement) |
| 1351 | 1351 | { |
| 1352 | - $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1352 | + $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
| 1353 | 1353 | |
| 1354 | 1354 | return static::create($str, $this->encoding); |
| 1355 | 1355 | } |
@@ -1398,7 +1398,7 @@ discard block |
||
| 1398 | 1398 | $truncated = UTF8::substr($truncated, 0, $lastPos, $encoding); |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | - $stringy->str = $truncated . $substring; |
|
| 1401 | + $stringy->str = $truncated.$substring; |
|
| 1402 | 1402 | |
| 1403 | 1403 | return $stringy; |
| 1404 | 1404 | } |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | $limit = -1; |
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | - $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
| 1594 | + $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
| 1595 | 1595 | |
| 1596 | 1596 | if ($limit > 0 && count($array) === $limit) { |
| 1597 | 1597 | array_pop($array); |
@@ -1665,13 +1665,13 @@ discard block |
||
| 1665 | 1665 | |
| 1666 | 1666 | $stringy->str = preg_replace_callback( |
| 1667 | 1667 | '/([\S]+)/u', |
| 1668 | - function ($match) use ($encoding, $ignore) { |
|
| 1668 | + function($match) use ($encoding, $ignore) { |
|
| 1669 | 1669 | if ($ignore && in_array($match[0], $ignore, true)) { |
| 1670 | 1670 | return $match[0]; |
| 1671 | 1671 | } else { |
| 1672 | 1672 | $stringy = new Stringy($match[0], $encoding); |
| 1673 | 1673 | |
| 1674 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
| 1674 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
| 1675 | 1675 | } |
| 1676 | 1676 | }, |
| 1677 | 1677 | $stringy->str |
@@ -1745,9 +1745,9 @@ discard block |
||
| 1745 | 1745 | if (array_key_exists($key, $map)) { |
| 1746 | 1746 | return $map[$key]; |
| 1747 | 1747 | } elseif (is_numeric($this->str)) { |
| 1748 | - return ((int)$this->str > 0); |
|
| 1748 | + return ((int) $this->str > 0); |
|
| 1749 | 1749 | } else { |
| 1750 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
| 1750 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
| 1751 | 1751 | } |
| 1752 | 1752 | } |
| 1753 | 1753 | |
@@ -1758,7 +1758,7 @@ discard block |
||
| 1758 | 1758 | */ |
| 1759 | 1759 | public function toString() |
| 1760 | 1760 | { |
| 1761 | - return (string)$this->str; |
|
| 1761 | + return (string) $this->str; |
|
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | 1764 | /** |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | $length -= $substringLength; |
| 1883 | 1883 | |
| 1884 | 1884 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
| 1885 | - $stringy->str = $truncated . $substring; |
|
| 1885 | + $stringy->str = $truncated.$substring; |
|
| 1886 | 1886 | |
| 1887 | 1887 | return $stringy; |
| 1888 | 1888 | } |
@@ -1927,7 +1927,7 @@ discard block |
||
| 1927 | 1927 | |
| 1928 | 1928 | $stringy->str = preg_replace_callback( |
| 1929 | 1929 | '/[-_\s]+(.)?/u', |
| 1930 | - function ($match) use ($encoding) { |
|
| 1930 | + function($match) use ($encoding) { |
|
| 1931 | 1931 | if (isset($match[1])) { |
| 1932 | 1932 | return UTF8::strtoupper($match[1], $encoding); |
| 1933 | 1933 | } else { |
@@ -1939,7 +1939,7 @@ discard block |
||
| 1939 | 1939 | |
| 1940 | 1940 | $stringy->str = preg_replace_callback( |
| 1941 | 1941 | '/[\d]+(.)?/u', |
| 1942 | - function ($match) use ($encoding) { |
|
| 1942 | + function($match) use ($encoding) { |
|
| 1943 | 1943 | return UTF8::strtoupper($match[0], $encoding); |
| 1944 | 1944 | }, |
| 1945 | 1945 | $stringy->str |
@@ -1962,14 +1962,14 @@ discard block |
||
| 1962 | 1962 | |
| 1963 | 1963 | $str = preg_replace_callback( |
| 1964 | 1964 | '/([\d|A-Z])/u', |
| 1965 | - function ($matches) { |
|
| 1965 | + function($matches) { |
|
| 1966 | 1966 | $match = $matches[1]; |
| 1967 | - $matchInt = (int)$match; |
|
| 1967 | + $matchInt = (int) $match; |
|
| 1968 | 1968 | |
| 1969 | 1969 | if ("$matchInt" == $match) { |
| 1970 | - return '_' . $match . '_'; |
|
| 1970 | + return '_'.$match.'_'; |
|
| 1971 | 1971 | } else { |
| 1972 | - return '_' . UTF8::strtolower($match); |
|
| 1972 | + return '_'.UTF8::strtolower($match); |
|
| 1973 | 1973 | } |
| 1974 | 1974 | }, |
| 1975 | 1975 | $str |
@@ -1978,9 +1978,9 @@ discard block |
||
| 1978 | 1978 | $str = preg_replace( |
| 1979 | 1979 | array( |
| 1980 | 1980 | |
| 1981 | - '/\s+/', // convert spaces to "_" |
|
| 1982 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 1983 | - '/_+/', // remove double "_" |
|
| 1981 | + '/\s+/', // convert spaces to "_" |
|
| 1982 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
| 1983 | + '/_+/', // remove double "_" |
|
| 1984 | 1984 | ), |
| 1985 | 1985 | array( |
| 1986 | 1986 | '_', |
@@ -2009,7 +2009,7 @@ discard block |
||
| 2009 | 2009 | $this->encoding |
| 2010 | 2010 | ); |
| 2011 | 2011 | |
| 2012 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
| 2012 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
| 2013 | 2013 | |
| 2014 | 2014 | return static::create($str, $this->encoding); |
| 2015 | 2015 | } |