@@ -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 | } |
@@ -2421,7 +2421,7 @@ discard block |
||
2421 | 2421 | /** |
2422 | 2422 | * @param string $word |
2423 | 2423 | * |
2424 | - * @return string |
|
2424 | + * @return Stringy |
|
2425 | 2425 | */ |
2426 | 2426 | protected function capitalizeWord($word) |
2427 | 2427 | { |
@@ -2440,7 +2440,7 @@ discard block |
||
2440 | 2440 | * @param string $names |
2441 | 2441 | * @param string $delimiter |
2442 | 2442 | * |
2443 | - * @return string |
|
2443 | + * @return Stringy |
|
2444 | 2444 | */ |
2445 | 2445 | protected function capitalizePersonalNameByDelimiter($names, $delimiter) |
2446 | 2446 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // init |
63 | 63 | UTF8::checkForSupport(); |
64 | 64 | |
65 | - $this->str = (string)$str; |
|
65 | + $this->str = (string) $str; |
|
66 | 66 | |
67 | 67 | if ($encoding) { |
68 | 68 | $this->encoding = $encoding; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function __toString() |
87 | 87 | { |
88 | - return (string)$this->str; |
|
88 | + return (string) $this->str; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function append($string) |
99 | 99 | { |
100 | - return static::create($this->str . $string, $this->encoding); |
|
100 | + return static::create($this->str.$string, $this->encoding); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function appendUniqueIdentifier($extraPrefix = '') |
125 | 125 | { |
126 | - $prefix = mt_rand() . |
|
127 | - session_id() . |
|
128 | - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') . |
|
129 | - (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '') . |
|
126 | + $prefix = mt_rand(). |
|
127 | + session_id(). |
|
128 | + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''). |
|
129 | + (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''). |
|
130 | 130 | $extraPrefix; |
131 | 131 | |
132 | - return $this->append(md5(uniqid($prefix, true) . $prefix)); |
|
132 | + return $this->append(md5(uniqid($prefix, true).$prefix)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | // init |
146 | 146 | $i = 0; |
147 | - $length = (int)$length; |
|
147 | + $length = (int) $length; |
|
148 | 148 | $str = $this->str; |
149 | 149 | $maxlength = UTF8::strlen($possibleChars, $this->encoding); |
150 | 150 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function indexOf($needle, $offset = 0) |
222 | 222 | { |
223 | - return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
223 | + return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | $str = preg_replace( |
305 | - '/' . $pattern . '/u' . $options, |
|
305 | + '/'.$pattern.'/u'.$options, |
|
306 | 306 | $replacement, |
307 | 307 | $this->str |
308 | 308 | ); |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $stringy = static::create($this->str, $this->encoding); |
464 | 464 | |
465 | 465 | if (!$stringy->startsWith($substring)) { |
466 | - $stringy->str = $substring . $stringy->str; |
|
466 | + $stringy->str = $substring.$stringy->str; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | return $stringy; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $endOfStr = UTF8::strtolower($endOfStr, $this->encoding); |
563 | 563 | } |
564 | 564 | |
565 | - return (string)$substring === $endOfStr; |
|
565 | + return (string) $substring === $endOfStr; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | */ |
684 | 684 | protected function matchesPattern($pattern) |
685 | 685 | { |
686 | - if (preg_match('/' . $pattern . '/u', $this->str)) { |
|
686 | + if (preg_match('/'.$pattern.'/u', $this->str)) { |
|
687 | 687 | return true; |
688 | 688 | } else { |
689 | 689 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $this->encoding |
758 | 758 | ); |
759 | 759 | |
760 | - $str = UTF8::strtoupper($first, $this->encoding) . $rest; |
|
760 | + $str = UTF8::strtoupper($first, $this->encoding).$rest; |
|
761 | 761 | |
762 | 762 | return static::create($str, $this->encoding); |
763 | 763 | } |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | */ |
776 | 776 | public function indexOfLast($needle, $offset = 0) |
777 | 777 | { |
778 | - return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding); |
|
778 | + return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding); |
797 | 797 | $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding); |
798 | 798 | |
799 | - $stringy->str = $start . $substring . $end; |
|
799 | + $stringy->str = $start.$substring.$end; |
|
800 | 800 | |
801 | 801 | return $stringy; |
802 | 802 | } |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | $quotedPattern = preg_quote($pattern, '/'); |
823 | 823 | $replaceWildCards = str_replace('\*', '.*', $quotedPattern); |
824 | 824 | |
825 | - return $this->matchesPattern('^' . $replaceWildCards . '\z'); |
|
825 | + return $this->matchesPattern('^'.$replaceWildCards.'\z'); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | $char = UTF8::substr($this->str, -$i, 1, $encoding); |
1060 | 1060 | |
1061 | 1061 | if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) { |
1062 | - $longestCommonSuffix = $char . $longestCommonSuffix; |
|
1062 | + $longestCommonSuffix = $char.$longestCommonSuffix; |
|
1063 | 1063 | } else { |
1064 | 1064 | break; |
1065 | 1065 | } |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | { |
1135 | 1135 | // init |
1136 | 1136 | $length = $this->length(); |
1137 | - $offset = (int)$offset; |
|
1137 | + $offset = (int) $offset; |
|
1138 | 1138 | |
1139 | 1139 | if ($offset >= 0) { |
1140 | 1140 | return ($length > $offset); |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | public function offsetGet($offset) |
1159 | 1159 | { |
1160 | 1160 | // init |
1161 | - $offset = (int)$offset; |
|
1161 | + $offset = (int) $offset; |
|
1162 | 1162 | $length = $this->length(); |
1163 | 1163 | |
1164 | 1164 | if ( |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | { |
1220 | 1220 | if (!in_array($padType, array('left', 'right', 'both'), true)) { |
1221 | 1221 | throw new \InvalidArgumentException( |
1222 | - 'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'" |
|
1222 | + 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" |
|
1223 | 1223 | ); |
1224 | 1224 | } |
1225 | 1225 | |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | $stringy->encoding |
1291 | 1291 | ); |
1292 | 1292 | |
1293 | - $stringy->str = $leftPadding . $stringy->str . $rightPadding; |
|
1293 | + $stringy->str = $leftPadding.$stringy->str.$rightPadding; |
|
1294 | 1294 | |
1295 | 1295 | return $stringy; |
1296 | 1296 | } |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | */ |
1335 | 1335 | public function prepend($string) |
1336 | 1336 | { |
1337 | - return static::create($string . $this->str, $this->encoding); |
|
1337 | + return static::create($string.$this->str, $this->encoding); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | */ |
1442 | 1442 | public function replaceBeginning($search, $replacement) |
1443 | 1443 | { |
1444 | - $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1444 | + $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1445 | 1445 | |
1446 | 1446 | return static::create($str, $this->encoding); |
1447 | 1447 | } |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | */ |
1457 | 1457 | public function replaceEnding($search, $replacement) |
1458 | 1458 | { |
1459 | - $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1459 | + $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement)); |
|
1460 | 1460 | |
1461 | 1461 | return static::create($str, $this->encoding); |
1462 | 1462 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | } |
1510 | 1510 | } |
1511 | 1511 | |
1512 | - $stringy->str = $truncated . $substring; |
|
1512 | + $stringy->str = $truncated.$substring; |
|
1513 | 1513 | |
1514 | 1514 | return $stringy; |
1515 | 1515 | } |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | $trimChars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&"; |
1632 | 1632 | |
1633 | 1633 | if ($length === null) { |
1634 | - $length = (int)round($this->length() / 2, 0); |
|
1634 | + $length = (int) round($this->length() / 2, 0); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | if (empty($search)) { |
@@ -1645,7 +1645,7 @@ discard block |
||
1645 | 1645 | rtrim( |
1646 | 1646 | UTF8::substr($text, 0, $pos, $this->encoding), |
1647 | 1647 | $trimChars |
1648 | - ) . $ellipsis, |
|
1648 | + ).$ellipsis, |
|
1649 | 1649 | $this->encoding |
1650 | 1650 | ); |
1651 | 1651 | } else { |
@@ -1660,7 +1660,7 @@ discard block |
||
1660 | 1660 | null, |
1661 | 1661 | $this->encoding |
1662 | 1662 | ); |
1663 | - $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1663 | + $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2); |
|
1664 | 1664 | |
1665 | 1665 | if ($halfSide > 0) { |
1666 | 1666 | |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | ) - $pos_start; |
1690 | 1690 | |
1691 | 1691 | if (!$pos_end || $pos_end <= 0) { |
1692 | - $extract = $ellipsis . ltrim( |
|
1692 | + $extract = $ellipsis.ltrim( |
|
1693 | 1693 | UTF8::substr( |
1694 | 1694 | $text, |
1695 | 1695 | $pos_start, |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | $trimChars |
1700 | 1700 | ); |
1701 | 1701 | } else { |
1702 | - $extract = $ellipsis . trim( |
|
1702 | + $extract = $ellipsis.trim( |
|
1703 | 1703 | UTF8::substr( |
1704 | 1704 | $text, |
1705 | 1705 | $pos_start, |
@@ -1707,7 +1707,7 @@ discard block |
||
1707 | 1707 | $this->encoding |
1708 | 1708 | ), |
1709 | 1709 | $trimChars |
1710 | - ) . $ellipsis; |
|
1710 | + ).$ellipsis; |
|
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | } else { |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | $extract = rtrim( |
1729 | 1729 | UTF8::substr($text, 0, $pos_end, $this->encoding), |
1730 | 1730 | $trimChars |
1731 | - ) . $ellipsis; |
|
1731 | + ).$ellipsis; |
|
1732 | 1732 | } else { |
1733 | 1733 | $extract = $text; |
1734 | 1734 | } |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | $limit = -1; |
1843 | 1843 | } |
1844 | 1844 | |
1845 | - $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit); |
|
1845 | + $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit); |
|
1846 | 1846 | |
1847 | 1847 | if ($limit > 0 && count($array) === $limit) { |
1848 | 1848 | array_pop($array); |
@@ -1916,13 +1916,13 @@ discard block |
||
1916 | 1916 | |
1917 | 1917 | $stringy->str = preg_replace_callback( |
1918 | 1918 | '/([\S]+)/u', |
1919 | - function ($match) use ($encoding, $ignore) { |
|
1919 | + function($match) use ($encoding, $ignore) { |
|
1920 | 1920 | if ($ignore && in_array($match[0], $ignore, true)) { |
1921 | 1921 | return $match[0]; |
1922 | 1922 | } else { |
1923 | 1923 | $stringy = new Stringy($match[0], $encoding); |
1924 | 1924 | |
1925 | - return (string)$stringy->toLowerCase()->upperCaseFirst(); |
|
1925 | + return (string) $stringy->toLowerCase()->upperCaseFirst(); |
|
1926 | 1926 | } |
1927 | 1927 | }, |
1928 | 1928 | $stringy->str |
@@ -1998,9 +1998,9 @@ discard block |
||
1998 | 1998 | if (array_key_exists($key, $map)) { |
1999 | 1999 | return $map[$key]; |
2000 | 2000 | } elseif (is_numeric($this->str)) { |
2001 | - return ((int)$this->str > 0); |
|
2001 | + return ((int) $this->str > 0); |
|
2002 | 2002 | } else { |
2003 | - return (bool)$this->regexReplace('[[:space:]]', '')->str; |
|
2003 | + return (bool) $this->regexReplace('[[:space:]]', '')->str; |
|
2004 | 2004 | } |
2005 | 2005 | } |
2006 | 2006 | |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | */ |
2012 | 2012 | public function toString() |
2013 | 2013 | { |
2014 | - return (string)$this->str; |
|
2014 | + return (string) $this->str; |
|
2015 | 2015 | } |
2016 | 2016 | |
2017 | 2017 | /** |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | $length -= $substringLength; |
2136 | 2136 | |
2137 | 2137 | $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding); |
2138 | - $stringy->str = $truncated . $substring; |
|
2138 | + $stringy->str = $truncated.$substring; |
|
2139 | 2139 | |
2140 | 2140 | return $stringy; |
2141 | 2141 | } |
@@ -2180,7 +2180,7 @@ discard block |
||
2180 | 2180 | |
2181 | 2181 | $stringy->str = preg_replace_callback( |
2182 | 2182 | '/[-_\s]+(.)?/u', |
2183 | - function ($match) use ($encoding) { |
|
2183 | + function($match) use ($encoding) { |
|
2184 | 2184 | if (isset($match[1])) { |
2185 | 2185 | return UTF8::strtoupper($match[1], $encoding); |
2186 | 2186 | } else { |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | |
2193 | 2193 | $stringy->str = preg_replace_callback( |
2194 | 2194 | '/[\d]+(.)?/u', |
2195 | - function ($match) use ($encoding) { |
|
2195 | + function($match) use ($encoding) { |
|
2196 | 2196 | return UTF8::strtoupper($match[0], $encoding); |
2197 | 2197 | }, |
2198 | 2198 | $stringy->str |
@@ -2216,14 +2216,14 @@ discard block |
||
2216 | 2216 | |
2217 | 2217 | $str = preg_replace_callback( |
2218 | 2218 | '/([\d|A-Z])/u', |
2219 | - function ($matches) use ($encoding) { |
|
2219 | + function($matches) use ($encoding) { |
|
2220 | 2220 | $match = $matches[1]; |
2221 | - $matchInt = (int)$match; |
|
2221 | + $matchInt = (int) $match; |
|
2222 | 2222 | |
2223 | 2223 | if ("$matchInt" == $match) { |
2224 | - return '_' . $match . '_'; |
|
2224 | + return '_'.$match.'_'; |
|
2225 | 2225 | } else { |
2226 | - return '_' . UTF8::strtolower($match, $encoding); |
|
2226 | + return '_'.UTF8::strtolower($match, $encoding); |
|
2227 | 2227 | } |
2228 | 2228 | }, |
2229 | 2229 | $str |
@@ -2232,9 +2232,9 @@ discard block |
||
2232 | 2232 | $str = preg_replace( |
2233 | 2233 | array( |
2234 | 2234 | |
2235 | - '/\s+/', // convert spaces to "_" |
|
2236 | - '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2237 | - '/_+/', // remove double "_" |
|
2235 | + '/\s+/', // convert spaces to "_" |
|
2236 | + '/^\s+|\s+$/', // trim leading & trailing spaces |
|
2237 | + '/_+/', // remove double "_" |
|
2238 | 2238 | ), |
2239 | 2239 | array( |
2240 | 2240 | '_', |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | $first = UTF8::substr($this->str, 0, 1, $this->encoding); |
2261 | 2261 | $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); |
2262 | 2262 | |
2263 | - $str = UTF8::strtolower($first, $this->encoding) . $rest; |
|
2263 | + $str = UTF8::strtolower($first, $this->encoding).$rest; |
|
2264 | 2264 | |
2265 | 2265 | return static::create($str, $this->encoding); |
2266 | 2266 | } |
@@ -2431,7 +2431,7 @@ discard block |
||
2431 | 2431 | $restOfWord = UTF8::substr($word, 1, null, $encoding); |
2432 | 2432 | $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding); |
2433 | 2433 | |
2434 | - return new static($firstCharacterUppercased . $restOfWord, $encoding); |
|
2434 | + return new static($firstCharacterUppercased.$restOfWord, $encoding); |
|
2435 | 2435 | } |
2436 | 2436 | |
2437 | 2437 | /** |
@@ -2445,7 +2445,7 @@ discard block |
||
2445 | 2445 | protected function capitalizePersonalNameByDelimiter($names, $delimiter) |
2446 | 2446 | { |
2447 | 2447 | // init |
2448 | - $names = explode((string)$delimiter, (string)$names); |
|
2448 | + $names = explode((string) $delimiter, (string) $names); |
|
2449 | 2449 | $encoding = $this->encoding; |
2450 | 2450 | |
2451 | 2451 | $specialCases = array( |