Completed
Push — master ( 04385c...e94879 )
by Lars
04:50
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 2 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.
Spacing   +49 added lines, -49 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
   /**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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, $this->encoding);
148 148
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
       $startOfStr = UTF8::strtolower($startOfStr, $this->encoding);
488 488
     }
489 489
 
490
-    return (string)$substring === $startOfStr;
490
+    return (string) $substring === $startOfStr;
491 491
   }
492 492
 
493 493
   /**
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
   }
Please login to merge, or discard this patch.