@@ -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); |
@@ -1579,9 +1579,9 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | $pos_end = min( |
1582 | - UTF8::strpos($text, ' ', $l, $this->encoding), |
|
1583 | - UTF8::strpos($text, '.', $l, $this->encoding) |
|
1584 | - ) - $pos_start; |
|
1582 | + UTF8::strpos($text, ' ', $l, $this->encoding), |
|
1583 | + UTF8::strpos($text, '.', $l, $this->encoding) |
|
1584 | + ) - $pos_start; |
|
1585 | 1585 | |
1586 | 1586 | if (!$pos_end || $pos_end <= 0) { |
1587 | 1587 | $extract = $ellipsis . ltrim( |
@@ -1621,9 +1621,9 @@ discard block |
||
1621 | 1621 | |
1622 | 1622 | if ($pos_end) { |
1623 | 1623 | $extract = rtrim( |
1624 | - UTF8::substr($text, 0, $pos_end, $this->encoding), |
|
1625 | - $trimChars |
|
1626 | - ) . $ellipsis; |
|
1624 | + UTF8::substr($text, 0, $pos_end, $this->encoding), |
|
1625 | + $trimChars |
|
1626 | + ) . $ellipsis; |
|
1627 | 1627 | } else { |
1628 | 1628 | $extract = $text; |
1629 | 1629 | } |
@@ -2316,7 +2316,7 @@ discard block |
||
2316 | 2316 | /** |
2317 | 2317 | * @param string $word |
2318 | 2318 | * |
2319 | - * @return string |
|
2319 | + * @return Stringy |
|
2320 | 2320 | */ |
2321 | 2321 | private function capitalizeWord($word) |
2322 | 2322 | { |
@@ -2335,7 +2335,7 @@ discard block |
||
2335 | 2335 | * @param string $names |
2336 | 2336 | * @param string $delimiter |
2337 | 2337 | * |
2338 | - * @return string |
|
2338 | + * @return Stringy |
|
2339 | 2339 | */ |
2340 | 2340 | private function capitalizePersonalNameByDelimiter($names, $delimiter) |
2341 | 2341 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // init |
62 | 62 | UTF8::checkForSupport(); |
63 | 63 | |
64 | - $this->str = (string)$str; |
|
64 | + $this->str = (string) $str; |
|
65 | 65 | |
66 | 66 | if ($encoding) { |
67 | 67 | $this->encoding = $encoding; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function __toString() |
86 | 86 | { |
87 | - return (string)$this->str; |
|
87 | + return (string) $this->str; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function append($string) |
98 | 98 | { |
99 | - return static::create($this->str . $string, $this->encoding); |
|
99 | + return static::create($this->str.$string, $this->encoding); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function appendUniqueIdentifier($extraPrefix = '') |
124 | 124 | { |
125 | - $prefix = mt_rand() . |
|
126 | - session_id() . |
|
127 | - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') . |
|
128 | - (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '') . |
|
125 | + $prefix = mt_rand(). |
|
126 | + session_id(). |
|
127 | + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''). |
|
128 | + (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''). |
|
129 | 129 | $extraPrefix; |
130 | 130 | |
131 | - return $this->append(md5(uniqid($prefix, true) . $prefix)); |
|
131 | + return $this->append(md5(uniqid($prefix, true).$prefix)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | // init |
145 | 145 | $i = 0; |
146 | - $length = (int)$length; |
|
146 | + $length = (int) $length; |
|
147 | 147 | $str = $this->str; |
148 | 148 | $maxlength = UTF8::strlen($possibleChars, $this->encoding); |
149 | 149 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function indexOf($needle, $offset = 0) |
221 | 221 | { |
222 | - return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
222 | + return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | $str = preg_replace( |
304 | - '/' . $pattern . '/u' . $options, |
|
304 | + '/'.$pattern.'/u'.$options, |
|
305 | 305 | $replacement, |
306 | 306 | $this->str |
307 | 307 | ); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $stringy = static::create($this->str, $this->encoding); |
463 | 463 | |
464 | 464 | if (!$stringy->startsWith($substring)) { |
465 | - $stringy->str = $substring . $stringy->str; |
|
465 | + $stringy->str = $substring.$stringy->str; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | return $stringy; |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $endOfStr = UTF8::strtolower($endOfStr, $this->encoding); |
537 | 537 | } |
538 | 538 | |
539 | - return (string)$substring === $endOfStr; |
|
539 | + return (string) $substring === $endOfStr; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | */ |
633 | 633 | private function matchesPattern($pattern) |
634 | 634 | { |
635 | - if (preg_match('/' . $pattern . '/u', $this->str)) { |
|
635 | + if (preg_match('/'.$pattern.'/u', $this->str)) { |
|
636 | 636 | return true; |
637 | 637 | } else { |
638 | 638 | return false; |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $this->encoding |
707 | 707 | ); |
708 | 708 | |
709 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
709 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
710 | 710 | |
711 | 711 | return static::create($str, $this->encoding); |
712 | 712 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | */ |
725 | 725 | public function indexOfLast($needle, $offset = 0) |
726 | 726 | { |
727 | - return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
727 | + return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding); |
746 | 746 | $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding); |
747 | 747 | |
748 | - $stringy->str = $start . $substring . $end; |
|
748 | + $stringy->str = $start.$substring.$end; |
|
749 | 749 | |
750 | 750 | return $stringy; |
751 | 751 | } |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
970 | 970 | |
971 | 971 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
972 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
972 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
973 | 973 | } else { |
974 | 974 | break; |
975 | 975 | } |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | { |
1045 | 1045 | // init |
1046 | 1046 | $length = $this->length(); |
1047 | - $offset = (int)$offset; |
|
1047 | + $offset = (int) $offset; |
|
1048 | 1048 | |
1049 | 1049 | if ($offset >= 0) { |
1050 | 1050 | return ($length > $offset); |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | public function offsetGet($offset) |
1069 | 1069 | { |
1070 | 1070 | // init |
1071 | - $offset = (int)$offset; |
|
1071 | + $offset = (int) $offset; |
|
1072 | 1072 | $length = $this->length(); |
1073 | 1073 | |
1074 | 1074 | if ( |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | { |
1130 | 1130 | if (!in_array($padType, array('left', 'right', 'both'), true)) { |
1131 | 1131 | throw new \InvalidArgumentException( |
1132 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
1132 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
1133 | 1133 | ); |
1134 | 1134 | } |
1135 | 1135 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | $stringy->encoding |
1201 | 1201 | ); |
1202 | 1202 | |
1203 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
1203 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
1204 | 1204 | |
1205 | 1205 | return $stringy; |
1206 | 1206 | } |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | */ |
1245 | 1245 | public function prepend($string) |
1246 | 1246 | { |
1247 | - return static::create($string . $this->str, $this->encoding); |
|
1247 | + return static::create($string.$this->str, $this->encoding); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | /** |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | */ |
1352 | 1352 | public function replaceBeginning($search, $replacement) |
1353 | 1353 | { |
1354 | - $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1354 | + $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1355 | 1355 | |
1356 | 1356 | return static::create($str, $this->encoding); |
1357 | 1357 | } |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | */ |
1367 | 1367 | public function replaceEnding($search, $replacement) |
1368 | 1368 | { |
1369 | - $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1369 | + $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1370 | 1370 | |
1371 | 1371 | return static::create($str, $this->encoding); |
1372 | 1372 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | $truncated = UTF8::substr($truncated, 0, $lastPos, $encoding); |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $stringy->str = $truncated . $substring; |
|
1418 | + $stringy->str = $truncated.$substring; |
|
1419 | 1419 | |
1420 | 1420 | return $stringy; |
1421 | 1421 | } |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | rtrim( |
1541 | 1541 | UTF8::substr($text, 0, $pos, $this->encoding), |
1542 | 1542 | $trimChars |
1543 | - ) . $ellipsis, |
|
1543 | + ).$ellipsis, |
|
1544 | 1544 | $this->encoding |
1545 | 1545 | ); |
1546 | 1546 | } else { |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | null, |
1556 | 1556 | $this->encoding |
1557 | 1557 | ); |
1558 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1558 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1559 | 1559 | |
1560 | 1560 | if ($halfSide > 0) { |
1561 | 1561 | |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | ) - $pos_start; |
1585 | 1585 | |
1586 | 1586 | if (!$pos_end || $pos_end <= 0) { |
1587 | - $extract = $ellipsis . ltrim( |
|
1587 | + $extract = $ellipsis.ltrim( |
|
1588 | 1588 | UTF8::substr( |
1589 | 1589 | $text, |
1590 | 1590 | $pos_start, |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | $trimChars |
1595 | 1595 | ); |
1596 | 1596 | } else { |
1597 | - $extract = $ellipsis . trim( |
|
1597 | + $extract = $ellipsis.trim( |
|
1598 | 1598 | UTF8::substr( |
1599 | 1599 | $text, |
1600 | 1600 | $pos_start, |
@@ -1602,7 +1602,7 @@ discard block |
||
1602 | 1602 | $this->encoding |
1603 | 1603 | ), |
1604 | 1604 | $trimChars |
1605 | - ) . $ellipsis; |
|
1605 | + ).$ellipsis; |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | } else { |
@@ -1623,7 +1623,7 @@ discard block |
||
1623 | 1623 | $extract = rtrim( |
1624 | 1624 | UTF8::substr($text, 0, $pos_end, $this->encoding), |
1625 | 1625 | $trimChars |
1626 | - ) . $ellipsis; |
|
1626 | + ).$ellipsis; |
|
1627 | 1627 | } else { |
1628 | 1628 | $extract = $text; |
1629 | 1629 | } |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | $limit = -1; |
1738 | 1738 | } |
1739 | 1739 | |
1740 | - $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
1740 | + $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
1741 | 1741 | |
1742 | 1742 | if ($limit > 0 && count($array) === $limit) { |
1743 | 1743 | array_pop($array); |
@@ -1811,13 +1811,13 @@ discard block |
||
1811 | 1811 | |
1812 | 1812 | $stringy->str = preg_replace_callback( |
1813 | 1813 | '/([\S]+)/u', |
1814 | - function ($match) use ($encoding, $ignore) { |
|
1814 | + function($match) use ($encoding, $ignore) { |
|
1815 | 1815 | if ($ignore && in_array($match[0], $ignore, true)) { |
1816 | 1816 | return $match[0]; |
1817 | 1817 | } else { |
1818 | 1818 | $stringy = new Stringy($match[0], $encoding); |
1819 | 1819 | |
1820 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
1820 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
1821 | 1821 | } |
1822 | 1822 | }, |
1823 | 1823 | $stringy->str |
@@ -1893,9 +1893,9 @@ discard block |
||
1893 | 1893 | if (array_key_exists($key, $map)) { |
1894 | 1894 | return $map[$key]; |
1895 | 1895 | } elseif (is_numeric($this->str)) { |
1896 | - return ((int)$this->str > 0); |
|
1896 | + return ((int) $this->str > 0); |
|
1897 | 1897 | } else { |
1898 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
1898 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
1899 | 1899 | } |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1906,7 +1906,7 @@ discard block |
||
1906 | 1906 | */ |
1907 | 1907 | public function toString() |
1908 | 1908 | { |
1909 | - return (string)$this->str; |
|
1909 | + return (string) $this->str; |
|
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | /** |
@@ -2030,7 +2030,7 @@ discard block |
||
2030 | 2030 | $length -= $substringLength; |
2031 | 2031 | |
2032 | 2032 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
2033 | - $stringy->str = $truncated . $substring; |
|
2033 | + $stringy->str = $truncated.$substring; |
|
2034 | 2034 | |
2035 | 2035 | return $stringy; |
2036 | 2036 | } |
@@ -2075,7 +2075,7 @@ discard block |
||
2075 | 2075 | |
2076 | 2076 | $stringy->str = preg_replace_callback( |
2077 | 2077 | '/[-_\s]+(.)?/u', |
2078 | - function ($match) use ($encoding) { |
|
2078 | + function($match) use ($encoding) { |
|
2079 | 2079 | if (isset($match[1])) { |
2080 | 2080 | return UTF8::strtoupper($match[1], $encoding); |
2081 | 2081 | } else { |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | |
2088 | 2088 | $stringy->str = preg_replace_callback( |
2089 | 2089 | '/[\d]+(.)?/u', |
2090 | - function ($match) use ($encoding) { |
|
2090 | + function($match) use ($encoding) { |
|
2091 | 2091 | return UTF8::strtoupper($match[0], $encoding); |
2092 | 2092 | }, |
2093 | 2093 | $stringy->str |
@@ -2111,14 +2111,14 @@ discard block |
||
2111 | 2111 | |
2112 | 2112 | $str = preg_replace_callback( |
2113 | 2113 | '/([\d|A-Z])/u', |
2114 | - function ($matches) use ($encoding) { |
|
2114 | + function($matches) use ($encoding) { |
|
2115 | 2115 | $match = $matches[1]; |
2116 | - $matchInt = (int)$match; |
|
2116 | + $matchInt = (int) $match; |
|
2117 | 2117 | |
2118 | 2118 | if ("$matchInt" == $match) { |
2119 | - return '_' . $match . '_'; |
|
2119 | + return '_'.$match.'_'; |
|
2120 | 2120 | } else { |
2121 | - return '_' . UTF8::strtolower($match, $encoding); |
|
2121 | + return '_'.UTF8::strtolower($match, $encoding); |
|
2122 | 2122 | } |
2123 | 2123 | }, |
2124 | 2124 | $str |
@@ -2127,9 +2127,9 @@ discard block |
||
2127 | 2127 | $str = preg_replace( |
2128 | 2128 | array( |
2129 | 2129 | |
2130 | - '/\s+/', // convert spaces to "_" |
|
2131 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2132 | - '/_+/', // remove double "_" |
|
2130 | + '/\s+/', // convert spaces to "_" |
|
2131 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2132 | + '/_+/', // remove double "_" |
|
2133 | 2133 | ), |
2134 | 2134 | array( |
2135 | 2135 | '_', |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | $first = UTF8::substr($this->str, 0, 1, $this->encoding); |
2156 | 2156 | $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); |
2157 | 2157 | |
2158 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
2158 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
2159 | 2159 | |
2160 | 2160 | return static::create($str, $this->encoding); |
2161 | 2161 | } |
@@ -2326,7 +2326,7 @@ discard block |
||
2326 | 2326 | $restOfWord = UTF8::substr($word, 1, null, $encoding); |
2327 | 2327 | $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding); |
2328 | 2328 | |
2329 | - return new static($firstCharacterUppercased . $restOfWord, $encoding); |
|
2329 | + return new static($firstCharacterUppercased.$restOfWord, $encoding); |
|
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | /** |