Completed
Push — master ( 9695e2...792b51 )
by Lars
19:09
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 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
   /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
    */
157 157
   public function indexOf($needle, $offset = 0)
158 158
   {
159
-    return UTF8::strpos($this->str, (string)$needle, (int)$offset, $this->encoding);
159
+    return UTF8::strpos($this->str, (string) $needle, (int) $offset, $this->encoding);
160 160
   }
161 161
 
162 162
   /**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     }
239 239
 
240 240
     $str = preg_replace(
241
-        '/' . $pattern . '/u' . $options,
241
+        '/'.$pattern.'/u'.$options,
242 242
         $replacement,
243 243
         $this->str
244 244
     );
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     $stringy = static::create($this->str, $this->encoding);
400 400
 
401 401
     if (!$stringy->startsWith($substring)) {
402
-      $stringy->str = $substring . $stringy->str;
402
+      $stringy->str = $substring.$stringy->str;
403 403
     }
404 404
 
405 405
     return $stringy;
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
       $startOfStr = UTF8::strtolower($startOfStr, $this->encoding);
429 429
     }
430 430
 
431
-    return (string)$substring === $startOfStr;
431
+    return (string) $substring === $startOfStr;
432 432
   }
433 433
 
434 434
   /**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
       $endOfStr = UTF8::strtolower($endOfStr, $this->encoding);
478 478
     }
479 479
 
480
-    return (string)$substring === $endOfStr;
480
+    return (string) $substring === $endOfStr;
481 481
   }
482 482
 
483 483
   /**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
    */
574 574
   private function matchesPattern($pattern)
575 575
   {
576
-    if (preg_match('/' . $pattern . '/u', $this->str)) {
576
+    if (preg_match('/'.$pattern.'/u', $this->str)) {
577 577
       return true;
578 578
     } else {
579 579
       return false;
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
         $this->encoding
648 648
     );
649 649
 
650
-    $str = UTF8::strtoupper($first, $this->encoding) . $rest;
650
+    $str = UTF8::strtoupper($first, $this->encoding).$rest;
651 651
 
652 652
     return static::create($str, $this->encoding);
653 653
   }
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
    */
666 666
   public function indexOfLast($needle, $offset = 0)
667 667
   {
668
-    return UTF8::strrpos($this->str, (string)$needle, (int)$offset, $this->encoding);
668
+    return UTF8::strrpos($this->str, (string) $needle, (int) $offset, $this->encoding);
669 669
   }
670 670
 
671 671
   /**
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
         $stringy->encoding
690 690
     );
691 691
 
692
-    $stringy->str = $start . $substring . $end;
692
+    $stringy->str = $start.$substring.$end;
693 693
 
694 694
     return $stringy;
695 695
   }
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
       $char = UTF8::substr($this->str, -$i, 1, $encoding);
891 891
 
892 892
       if ($char == UTF8::substr($otherStr, -$i, 1, $encoding)) {
893
-        $longestCommonSuffix = $char . $longestCommonSuffix;
893
+        $longestCommonSuffix = $char.$longestCommonSuffix;
894 894
       } else {
895 895
         break;
896 896
       }
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
   {
966 966
     // init
967 967
     $length = $this->length();
968
-    $offset = (int)$offset;
968
+    $offset = (int) $offset;
969 969
 
970 970
     if ($offset >= 0) {
971 971
       return ($length > $offset);
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
   public function offsetGet($offset)
990 990
   {
991 991
     // init
992
-    $offset = (int)$offset;
992
+    $offset = (int) $offset;
993 993
     $length = $this->length();
994 994
 
995 995
     if (
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
   {
1051 1051
     if (!in_array($padType, array('left', 'right', 'both'), true)) {
1052 1052
       throw new \InvalidArgumentException(
1053
-          'Pad expects $padType ' . "to be one of 'left', 'right' or 'both'"
1053
+          'Pad expects $padType '."to be one of 'left', 'right' or 'both'"
1054 1054
       );
1055 1055
     }
1056 1056
 
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
         $stringy->encoding
1122 1122
     );
1123 1123
 
1124
-    $stringy->str = $leftPadding . $stringy->str . $rightPadding;
1124
+    $stringy->str = $leftPadding.$stringy->str.$rightPadding;
1125 1125
 
1126 1126
     return $stringy;
1127 1127
   }
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
    */
1166 1166
   public function prepend($string)
1167 1167
   {
1168
-    return static::create($string . $this->str, $this->encoding);
1168
+    return static::create($string.$this->str, $this->encoding);
1169 1169
   }
1170 1170
 
1171 1171
   /**
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
    */
1273 1273
   public function replaceBeginning($search, $replacement)
1274 1274
   {
1275
-    $str = $this->regexReplace('^' . preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement));
1275
+    $str = $this->regexReplace('^'.preg_quote($search, '/'), UTF8::str_replace('\\', '\\\\', $replacement));
1276 1276
 
1277 1277
     return static::create($str, $this->encoding);
1278 1278
   }
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
    */
1288 1288
   public function replaceEnding($search, $replacement)
1289 1289
   {
1290
-    $str = $this->regexReplace(preg_quote($search, '/') . '$', UTF8::str_replace('\\', '\\\\', $replacement));
1290
+    $str = $this->regexReplace(preg_quote($search, '/').'$', UTF8::str_replace('\\', '\\\\', $replacement));
1291 1291
 
1292 1292
     return static::create($str, $this->encoding);
1293 1293
   }
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
       $truncated = UTF8::substr($truncated, 0, $lastPos, $encoding);
1337 1337
     }
1338 1338
 
1339
-    $stringy->str = $truncated . $substring;
1339
+    $stringy->str = $truncated.$substring;
1340 1340
 
1341 1341
     return $stringy;
1342 1342
   }
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
       $limit = -1;
1495 1495
     }
1496 1496
 
1497
-    $array = preg_split('/' . preg_quote($pattern, '/') . '/u', $this->str, $limit);
1497
+    $array = preg_split('/'.preg_quote($pattern, '/').'/u', $this->str, $limit);
1498 1498
 
1499 1499
     if ($limit > 0 && count($array) === $limit) {
1500 1500
       array_pop($array);
@@ -1568,13 +1568,13 @@  discard block
 block discarded – undo
1568 1568
 
1569 1569
     $stringy->str = preg_replace_callback(
1570 1570
         '/([\S]+)/u',
1571
-        function ($match) use ($encoding, $ignore) {
1571
+        function($match) use ($encoding, $ignore) {
1572 1572
           if ($ignore && in_array($match[0], $ignore, true)) {
1573 1573
             return $match[0];
1574 1574
           } else {
1575 1575
             $stringy = new Stringy($match[0], $encoding);
1576 1576
 
1577
-            return (string)$stringy->toLowerCase()->upperCaseFirst();
1577
+            return (string) $stringy->toLowerCase()->upperCaseFirst();
1578 1578
           }
1579 1579
         },
1580 1580
         $stringy->str
@@ -1648,9 +1648,9 @@  discard block
 block discarded – undo
1648 1648
     if (array_key_exists($key, $map)) {
1649 1649
       return $map[$key];
1650 1650
     } elseif (is_numeric($this->str)) {
1651
-      return ((int)$this->str > 0);
1651
+      return ((int) $this->str > 0);
1652 1652
     } else {
1653
-      return (bool)$this->regexReplace('[[:space:]]', '')->str;
1653
+      return (bool) $this->regexReplace('[[:space:]]', '')->str;
1654 1654
     }
1655 1655
   }
1656 1656
 
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
    */
1662 1662
   public function toString()
1663 1663
   {
1664
-    return (string)$this->str;
1664
+    return (string) $this->str;
1665 1665
   }
1666 1666
 
1667 1667
   /**
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     $length -= $substringLength;
1786 1786
 
1787 1787
     $truncated = UTF8::substr($stringy->str, 0, $length, $stringy->encoding);
1788
-    $stringy->str = $truncated . $substring;
1788
+    $stringy->str = $truncated.$substring;
1789 1789
 
1790 1790
     return $stringy;
1791 1791
   }
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 
1831 1831
     $stringy->str = preg_replace_callback(
1832 1832
         '/[-_\s]+(.)?/u',
1833
-        function ($match) use ($encoding) {
1833
+        function($match) use ($encoding) {
1834 1834
           if (isset($match[1])) {
1835 1835
             return UTF8::strtoupper($match[1], $encoding);
1836 1836
           } else {
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 
1843 1843
     $stringy->str = preg_replace_callback(
1844 1844
         '/[\d]+(.)?/u',
1845
-        function ($match) use ($encoding) {
1845
+        function($match) use ($encoding) {
1846 1846
           return UTF8::strtoupper($match[0], $encoding);
1847 1847
         },
1848 1848
         $stringy->str
@@ -1865,14 +1865,14 @@  discard block
 block discarded – undo
1865 1865
 
1866 1866
     $str = preg_replace_callback(
1867 1867
         '/([\d|A-Z])/u',
1868
-        function ($matches) {
1868
+        function($matches) {
1869 1869
           $match = $matches[1];
1870
-          $matchInt = (int)$match;
1870
+          $matchInt = (int) $match;
1871 1871
 
1872 1872
           if ("$matchInt" == $match) {
1873
-            return '_' . $match . '_';
1873
+            return '_'.$match.'_';
1874 1874
           } else {
1875
-            return '_' . UTF8::strtolower($match);
1875
+            return '_'.UTF8::strtolower($match);
1876 1876
           }
1877 1877
         },
1878 1878
         $str
@@ -1881,9 +1881,9 @@  discard block
 block discarded – undo
1881 1881
     $str = preg_replace(
1882 1882
         array(
1883 1883
 
1884
-            '/\s+/',      // convert spaces to "_"
1885
-            '/^\s+|\s+$/',  // trim leading & trailing spaces
1886
-            '/_+/',         // remove double "_"
1884
+            '/\s+/', // convert spaces to "_"
1885
+            '/^\s+|\s+$/', // trim leading & trailing spaces
1886
+            '/_+/', // remove double "_"
1887 1887
         ),
1888 1888
         array(
1889 1889
             '_',
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
         $this->encoding
1913 1913
     );
1914 1914
 
1915
-    $str = UTF8::strtolower($first, $this->encoding) . $rest;
1915
+    $str = UTF8::strtolower($first, $this->encoding).$rest;
1916 1916
 
1917 1917
     return static::create($str, $this->encoding);
1918 1918
   }
Please login to merge, or discard this patch.