Completed
Push — master ( ddcc47...bedd78 )
by Lars
02:12
created
src/StaticStringy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Stringy.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1579,9 +1579,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
       }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2316,7 +2316,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
   {
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Stringy;
6 6
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     // init
65 65
     UTF8::checkForSupport();
66 66
 
67
-    $this->str = (string)$str;
67
+    $this->str = (string) $str;
68 68
 
69 69
     if ($encoding) {
70 70
       $this->encoding = $encoding;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
    */
88 88
   public function __toString()
89 89
   {
90
-    return (string)$this->str;
90
+    return (string) $this->str;
91 91
   }
92 92
 
93 93
   /**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
    */
100 100
   public function append($string)
101 101
   {
102
-    return static::create($this->str . $string, $this->encoding);
102
+    return static::create($this->str.$string, $this->encoding);
103 103
   }
104 104
 
105 105
   /**
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
    */
126 126
   public function appendUniqueIdentifier($extraPrefix = '')
127 127
   {
128
-    $prefix = mt_rand() .
129
-              session_id() .
130
-              (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') .
131
-              (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '') .
128
+    $prefix = mt_rand().
129
+              session_id().
130
+              (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '').
131
+              (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '').
132 132
               $extraPrefix;
133 133
 
134
-    return $this->append(md5(uniqid($prefix, true) . $prefix));
134
+    return $this->append(md5(uniqid($prefix, true).$prefix));
135 135
   }
136 136
 
137 137
   /**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
   {
147 147
     // init
148 148
     $i = 0;
149
-    $length = (int)$length;
149
+    $length = (int) $length;
150 150
     $str = $this->str;
151 151
     $maxlength = UTF8::strlen($possibleChars, $this->encoding);
152 152
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
    */
223 223
   public function indexOf($needle, $offset = 0)
224 224
   {
225
-    return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding);
225
+    return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding);
226 226
   }
227 227
 
228 228
   /**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     $str = preg_replace(
307
-        '/' . $pattern . '/u' . $options,
307
+        '/'.$pattern.'/u'.$options,
308 308
         $replacement,
309 309
         $this->str
310 310
     );
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     $stringy = static::create($this->str, $this->encoding);
466 466
 
467 467
     if (!$stringy->startsWith($substring)) {
468
-      $stringy->str = $substring . $stringy->str;
468
+      $stringy->str = $substring.$stringy->str;
469 469
     }
470 470
 
471 471
     return $stringy;
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
       $endOfStr = UTF8::strtolower($endOfStr, $this->encoding);
565 565
     }
566 566
 
567
-    return (string)$substring === $endOfStr;
567
+    return (string) $substring === $endOfStr;
568 568
   }
569 569
 
570 570
   /**
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
    */
661 661
   private function matchesPattern($pattern)
662 662
   {
663
-    if (preg_match('/' . $pattern . '/u', $this->str)) {
663
+    if (preg_match('/'.$pattern.'/u', $this->str)) {
664 664
       return true;
665 665
     } else {
666 666
       return false;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
         $this->encoding
735 735
     );
736 736
 
737
-    $str = UTF8::strtoupper($first, $this->encoding) . $rest;
737
+    $str = UTF8::strtoupper($first, $this->encoding).$rest;
738 738
 
739 739
     return static::create($str, $this->encoding);
740 740
   }
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
    */
753 753
   public function indexOfLast($needle, $offset = 0)
754 754
   {
755
-    return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding);
755
+    return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding);
756 756
   }
757 757
 
758 758
   /**
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
     $start = UTF8::substr($stringy->str, 0, $index, $stringy->encoding);
774 774
     $end = UTF8::substr($stringy->str, $index, $stringy->length(), $stringy->encoding);
775 775
 
776
-    $stringy->str = $start . $substring . $end;
776
+    $stringy->str = $start.$substring.$end;
777 777
 
778 778
     return $stringy;
779 779
   }
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
     $quotedPattern = preg_quote($pattern, '/');
800 800
     $replaceWildCards = str_replace('\*', '.*', $quotedPattern);
801 801
 
802
-    return $this->matchesPattern('^' . $replaceWildCards . '\z');
802
+    return $this->matchesPattern('^'.$replaceWildCards.'\z');
803 803
   }
804 804
 
805 805
   /**
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
       $char = UTF8::substr($this->str, -$i, 1, $encoding);
1037 1037
 
1038 1038
       if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) {
1039
-        $longestCommonSuffix = $char . $longestCommonSuffix;
1039
+        $longestCommonSuffix = $char.$longestCommonSuffix;
1040 1040
       } else {
1041 1041
         break;
1042 1042
       }
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
   {
1112 1112
     // init
1113 1113
     $length = $this->length();
1114
-    $offset = (int)$offset;
1114
+    $offset = (int) $offset;
1115 1115
 
1116 1116
     if ($offset >= 0) {
1117 1117
       return ($length > $offset);
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
   public function offsetGet($offset)
1136 1136
   {
1137 1137
     // init
1138
-    $offset = (int)$offset;
1138
+    $offset = (int) $offset;
1139 1139
     $length = $this->length();
1140 1140
 
1141 1141
     if (
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
   {
1197 1197
     if (!in_array($padType, array('left', 'right', 'both'), true)) {
1198 1198
       throw new \InvalidArgumentException(
1199
-          'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'"
1199
+          'Pad expects $padType '."to be one of 'left', 'right' or 'both'"
1200 1200
       );
1201 1201
     }
1202 1202
 
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
         $stringy->encoding
1268 1268
     );
1269 1269
 
1270
-    $stringy->str = $leftPadding . $stringy->str . $rightPadding;
1270
+    $stringy->str = $leftPadding.$stringy->str.$rightPadding;
1271 1271
 
1272 1272
     return $stringy;
1273 1273
   }
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
    */
1312 1312
   public function prepend($string)
1313 1313
   {
1314
-    return static::create($string . $this->str, $this->encoding);
1314
+    return static::create($string.$this->str, $this->encoding);
1315 1315
   }
1316 1316
 
1317 1317
   /**
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
    */
1419 1419
   public function replaceBeginning($search, $replacement)
1420 1420
   {
1421
-    $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement));
1421
+    $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement));
1422 1422
 
1423 1423
     return static::create($str, $this->encoding);
1424 1424
   }
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
    */
1434 1434
   public function replaceEnding($search, $replacement)
1435 1435
   {
1436
-    $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement));
1436
+    $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement));
1437 1437
 
1438 1438
     return static::create($str, $this->encoding);
1439 1439
   }
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
       }
1487 1487
     }
1488 1488
 
1489
-    $stringy->str = $truncated . $substring;
1489
+    $stringy->str = $truncated.$substring;
1490 1490
 
1491 1491
     return $stringy;
1492 1492
   }
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
     $trimChars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&";
1598 1598
 
1599 1599
     if ($length === null) {
1600
-      $length = (int)round($this->length() / 2, 0);
1600
+      $length = (int) round($this->length() / 2, 0);
1601 1601
     }
1602 1602
 
1603 1603
     if (empty($search)) {
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
             rtrim(
1612 1612
                 UTF8::substr($text, 0, $pos, $this->encoding),
1613 1613
                 $trimChars
1614
-            ) . $ellipsis,
1614
+            ).$ellipsis,
1615 1615
             $this->encoding
1616 1616
         );
1617 1617
       } else {
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
         null,
1627 1627
         $this->encoding
1628 1628
     );
1629
-    $halfSide = (int)($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2);
1629
+    $halfSide = (int) ($wordPos - $length / 2 + UTF8::strlen($search, $this->encoding) / 2);
1630 1630
 
1631 1631
     if ($halfSide > 0) {
1632 1632
 
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
                  ) - $pos_start;
1656 1656
 
1657 1657
       if (!$pos_end || $pos_end <= 0) {
1658
-        $extract = $ellipsis . ltrim(
1658
+        $extract = $ellipsis.ltrim(
1659 1659
                 UTF8::substr(
1660 1660
                     $text,
1661 1661
                     $pos_start,
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
                 $trimChars
1666 1666
             );
1667 1667
       } else {
1668
-        $extract = $ellipsis . trim(
1668
+        $extract = $ellipsis.trim(
1669 1669
                 UTF8::substr(
1670 1670
                     $text,
1671 1671
                     $pos_start,
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
                     $this->encoding
1674 1674
                 ),
1675 1675
                 $trimChars
1676
-            ) . $ellipsis;
1676
+            ).$ellipsis;
1677 1677
       }
1678 1678
 
1679 1679
     } else {
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
         $extract = rtrim(
1695 1695
                        UTF8::substr($text, 0, $pos_end, $this->encoding),
1696 1696
                        $trimChars
1697
-                   ) . $ellipsis;
1697
+                   ).$ellipsis;
1698 1698
       } else {
1699 1699
         $extract = $text;
1700 1700
       }
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
       $limit = -1;
1809 1809
     }
1810 1810
 
1811
-    $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit);
1811
+    $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit);
1812 1812
 
1813 1813
     if ($limit > 0 && count($array) === $limit) {
1814 1814
       array_pop($array);
@@ -1882,13 +1882,13 @@  discard block
 block discarded – undo
1882 1882
 
1883 1883
     $stringy->str = preg_replace_callback(
1884 1884
         '/([\S]+)/u',
1885
-        function ($match) use ($encoding, $ignore) {
1885
+        function($match) use ($encoding, $ignore) {
1886 1886
           if ($ignore && in_array($match[0], $ignore, true)) {
1887 1887
             return $match[0];
1888 1888
           } else {
1889 1889
             $stringy = new Stringy($match[0], $encoding);
1890 1890
 
1891
-            return (string)$stringy->toLowerCase()->upperCaseFirst();
1891
+            return (string) $stringy->toLowerCase()->upperCaseFirst();
1892 1892
           }
1893 1893
         },
1894 1894
         $stringy->str
@@ -1964,9 +1964,9 @@  discard block
 block discarded – undo
1964 1964
     if (array_key_exists($key, $map)) {
1965 1965
       return $map[$key];
1966 1966
     } elseif (is_numeric($this->str)) {
1967
-      return ((int)$this->str > 0);
1967
+      return ((int) $this->str > 0);
1968 1968
     } else {
1969
-      return (bool)$this->regexReplace('[[:space:]]', '')->str;
1969
+      return (bool) $this->regexReplace('[[:space:]]', '')->str;
1970 1970
     }
1971 1971
   }
1972 1972
 
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
    */
1978 1978
   public function toString()
1979 1979
   {
1980
-    return (string)$this->str;
1980
+    return (string) $this->str;
1981 1981
   }
1982 1982
 
1983 1983
   /**
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
     $length -= $substringLength;
2102 2102
 
2103 2103
     $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding);
2104
-    $stringy->str = $truncated . $substring;
2104
+    $stringy->str = $truncated.$substring;
2105 2105
 
2106 2106
     return $stringy;
2107 2107
   }
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 
2147 2147
     $stringy->str = preg_replace_callback(
2148 2148
         '/[-_\s]+(.)?/u',
2149
-        function ($match) use ($encoding) {
2149
+        function($match) use ($encoding) {
2150 2150
           if (isset($match[1])) {
2151 2151
             return UTF8::strtoupper($match[1], $encoding);
2152 2152
           } else {
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
 
2159 2159
     $stringy->str = preg_replace_callback(
2160 2160
         '/[\d]+(.)?/u',
2161
-        function ($match) use ($encoding) {
2161
+        function($match) use ($encoding) {
2162 2162
           return UTF8::strtoupper($match[0], $encoding);
2163 2163
         },
2164 2164
         $stringy->str
@@ -2182,14 +2182,14 @@  discard block
 block discarded – undo
2182 2182
 
2183 2183
     $str = preg_replace_callback(
2184 2184
         '/([\d|A-Z])/u',
2185
-        function ($matches) use ($encoding) {
2185
+        function($matches) use ($encoding) {
2186 2186
           $match = $matches[1];
2187
-          $matchInt = (int)$match;
2187
+          $matchInt = (int) $match;
2188 2188
 
2189 2189
           if ("$matchInt" == $match) {
2190
-            return '_' . $match . '_';
2190
+            return '_'.$match.'_';
2191 2191
           } else {
2192
-            return '_' . UTF8::strtolower($match, $encoding);
2192
+            return '_'.UTF8::strtolower($match, $encoding);
2193 2193
           }
2194 2194
         },
2195 2195
         $str
@@ -2198,9 +2198,9 @@  discard block
 block discarded – undo
2198 2198
     $str = preg_replace(
2199 2199
         array(
2200 2200
 
2201
-            '/\s+/',      // convert spaces to "_"
2202
-            '/^\s+|\s+$/',  // trim leading & trailing spaces
2203
-            '/_+/',         // remove double "_"
2201
+            '/\s+/', // convert spaces to "_"
2202
+            '/^\s+|\s+$/', // trim leading & trailing spaces
2203
+            '/_+/', // remove double "_"
2204 2204
         ),
2205 2205
         array(
2206 2206
             '_',
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
     $first = UTF8::substr($this->str, 0, 1, $this->encoding);
2227 2227
     $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding);
2228 2228
 
2229
-    $str = UTF8::strtolower($first, $this->encoding) . $rest;
2229
+    $str = UTF8::strtolower($first, $this->encoding).$rest;
2230 2230
 
2231 2231
     return static::create($str, $this->encoding);
2232 2232
   }
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
     $restOfWord = UTF8::substr($word, 1, null, $encoding);
2398 2398
     $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding);
2399 2399
 
2400
-    return new static($firstCharacterUppercased . $restOfWord, $encoding);
2400
+    return new static($firstCharacterUppercased.$restOfWord, $encoding);
2401 2401
   }
2402 2402
 
2403 2403
   /**
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
   private function capitalizePersonalNameByDelimiter($names, $delimiter)
2412 2412
   {
2413 2413
     // init
2414
-    $names = explode((string)$delimiter, (string)$names);
2414
+    $names = explode((string) $delimiter, (string) $names);
2415 2415
     $encoding = $this->encoding;
2416 2416
 
2417 2417
     $specialCases = array(
Please login to merge, or discard this patch.