@@ -110,8 +110,7 @@ |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $toBeAppended = $string; |
| 113 | - } |
|
| 114 | - else |
|
| 113 | + } else |
|
| 115 | 114 | { |
| 116 | 115 | // Ensure the incoming string is string like... Str will throw |
| 117 | 116 | // exceptions if not. We also make the assumption that any "scalar" |
@@ -27,8 +27,7 @@ discard block |
||
| 27 | 27 | if ($this->startsWith($substring)) |
| 28 | 28 | { |
| 29 | 29 | return $this; |
| 30 | - } |
|
| 31 | - else |
|
| 30 | + } else |
|
| 32 | 31 | { |
| 33 | 32 | return $this->newSelf($substring.$this->scalarString); |
| 34 | 33 | } |
@@ -46,8 +45,7 @@ discard block |
||
| 46 | 45 | if ($this->endsWith($substring)) |
| 47 | 46 | { |
| 48 | 47 | return $this; |
| 49 | - } |
|
| 50 | - else |
|
| 48 | + } else |
|
| 51 | 49 | { |
| 52 | 50 | return $this->newSelf($this->scalarString.$substring); |
| 53 | 51 | } |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function insert($substring, $index) |
| 66 | 66 | { |
| 67 | - if ($index > $this->getLength()) throw new \OutOfBoundsException(); |
|
| 67 | + if ($index > $this->getLength()) { |
|
| 68 | + throw new \OutOfBoundsException(); |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | $start = UTF8::substr |
| 70 | 72 | ( |
@@ -149,16 +151,13 @@ discard block |
||
| 149 | 151 | if ($end === null) |
| 150 | 152 | { |
| 151 | 153 | $length = $this->getLength(); |
| 152 | - } |
|
| 153 | - elseif ($end >= 0 && $end <= $start) |
|
| 154 | + } elseif ($end >= 0 && $end <= $start) |
|
| 154 | 155 | { |
| 155 | 156 | return $this->newSelf(''); |
| 156 | - } |
|
| 157 | - elseif ($end < 0) |
|
| 157 | + } elseif ($end < 0) |
|
| 158 | 158 | { |
| 159 | 159 | $length = $this->getLength() + $end - $start; |
| 160 | - } |
|
| 161 | - else |
|
| 160 | + } else |
|
| 162 | 161 | { |
| 163 | 162 | $length = $end - $start; |
| 164 | 163 | } |
@@ -35,12 +35,16 @@ discard block |
||
| 35 | 35 | public function between($start, $end, $offset = 0, $include = false) |
| 36 | 36 | { |
| 37 | 37 | $startIndex = $this->indexOf($start, $offset); |
| 38 | - if ($startIndex === false) return $this->newSelf(''); |
|
| 38 | + if ($startIndex === false) { |
|
| 39 | + return $this->newSelf(''); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | $substrIndex = $startIndex + UTF8::strlen($start, $this->encoding); |
| 41 | 43 | |
| 42 | 44 | $endIndex = $this->indexOf($end, $substrIndex); |
| 43 | - if ($endIndex === false) return $this->newSelf(''); |
|
| 45 | + if ($endIndex === false) { |
|
| 46 | + return $this->newSelf(''); |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | 49 | $result = UTF8::substr |
| 46 | 50 | ( |
@@ -50,7 +54,9 @@ discard block |
||
| 50 | 54 | $this->encoding |
| 51 | 55 | ); |
| 52 | 56 | |
| 53 | - if ($include === true) $result = $start.$result.$end; |
|
| 57 | + if ($include === true) { |
|
| 58 | + $result = $start.$result.$end; |
|
| 59 | + } |
|
| 54 | 60 | |
| 55 | 61 | return $this->newSelf($result); |
| 56 | 62 | } |
@@ -160,12 +160,10 @@ discard block |
||
| 160 | 160 | if (array_key_exists($key, $map)) |
| 161 | 161 | { |
| 162 | 162 | return $map[$key]; |
| 163 | - } |
|
| 164 | - elseif (is_numeric($this->scalarString)) |
|
| 163 | + } elseif (is_numeric($this->scalarString)) |
|
| 165 | 164 | { |
| 166 | 165 | return ((int)$this->scalarString > 0); |
| 167 | - } |
|
| 168 | - else |
|
| 166 | + } else |
|
| 169 | 167 | { |
| 170 | 168 | return (bool)$this->regexReplace('[[:space:]]', '')->scalarString; |
| 171 | 169 | } |
@@ -271,8 +269,7 @@ discard block |
||
| 271 | 269 | if (isset($match[1])) |
| 272 | 270 | { |
| 273 | 271 | return UTF8::strtoupper($match[1], $this->encoding); |
| 274 | - } |
|
| 275 | - else |
|
| 272 | + } else |
|
| 276 | 273 | { |
| 277 | 274 | return ''; |
| 278 | 275 | } |
@@ -292,7 +289,9 @@ discard block |
||
| 292 | 289 | |
| 293 | 290 | $camelCase = $this->newSelf($camelCase); |
| 294 | 291 | |
| 295 | - if ($upperFirst === true) $camelCase = $camelCase->upperCaseFirst(); |
|
| 292 | + if ($upperFirst === true) { |
|
| 293 | + $camelCase = $camelCase->upperCaseFirst(); |
|
| 294 | + } |
|
| 296 | 295 | |
| 297 | 296 | return $camelCase; |
| 298 | 297 | } |
@@ -319,8 +318,7 @@ discard block |
||
| 319 | 318 | if ("$matchInt" == $match) |
| 320 | 319 | { |
| 321 | 320 | return '_' . $match . '_'; |
| 322 | - } |
|
| 323 | - else |
|
| 321 | + } else |
|
| 324 | 322 | { |
| 325 | 323 | return '_' . UTF8::strtolower($match, $this->encoding); |
| 326 | 324 | } |
@@ -372,8 +370,7 @@ discard block |
||
| 372 | 370 | if ($ignore && in_array($match[0], $ignore, true)) |
| 373 | 371 | { |
| 374 | 372 | return $match[0]; |
| 375 | - } |
|
| 376 | - else |
|
| 373 | + } else |
|
| 377 | 374 | { |
| 378 | 375 | return (string)$this->newSelf($match[0]) |
| 379 | 376 | ->toLowerCase()->upperCaseFirst(); |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | $replacement, |
| 37 | 37 | $this->scalarString |
| 38 | 38 | ); |
| 39 | - } |
|
| 40 | - else |
|
| 39 | + } else |
|
| 41 | 40 | { |
| 42 | 41 | $return = UTF8::str_ireplace |
| 43 | 42 | ( |
@@ -71,8 +70,12 @@ discard block |
||
| 71 | 70 | */ |
| 72 | 71 | public function replaceExact($search, $replacement) |
| 73 | 72 | { |
| 74 | - if (!is_array($search)) $search = [$search]; |
|
| 75 | - if (!is_array($replacement)) $replacement = [$replacement]; |
|
| 73 | + if (!is_array($search)) { |
|
| 74 | + $search = [$search]; |
|
| 75 | + } |
|
| 76 | + if (!is_array($replacement)) { |
|
| 77 | + $replacement = [$replacement]; |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | if (count($search) !== count($replacement)) |
| 78 | 81 | { |
@@ -30,7 +30,9 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function truncate($length, $substring = '') |
| 32 | 32 | { |
| 33 | - if ($length >= $this->getLength()) return $this; |
|
| 33 | + if ($length >= $this->getLength()) { |
|
| 34 | + return $this; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // Need to further trim the string so we can append the substring |
| 36 | 38 | $substringLength = UTF8::strlen($substring, $this->encoding); |
@@ -63,7 +65,9 @@ discard block |
||
| 63 | 65 | */ |
| 64 | 66 | public function safeTruncate($length, $substring = '') |
| 65 | 67 | { |
| 66 | - if ($length >= $this->getLength()) return $this; |
|
| 68 | + if ($length >= $this->getLength()) { |
|
| 69 | + return $this; |
|
| 70 | + } |
|
| 67 | 71 | |
| 68 | 72 | // Need to further trim the string so we can append the substring |
| 69 | 73 | $substringLength = UTF8::strlen($substring, $this->encoding); |
@@ -116,7 +116,9 @@ |
||
| 116 | 116 | $strLength = $this->getLength(); |
| 117 | 117 | $paddedLength = $strLength + $left + $right; |
| 118 | 118 | |
| 119 | - if (!$length || $paddedLength <= $strLength) return $this; |
|
| 119 | + if (!$length || $paddedLength <= $strLength) { |
|
| 120 | + return $this; |
|
| 121 | + } |
|
| 120 | 122 | |
| 121 | 123 | $leftPadding = UTF8::substr |
| 122 | 124 | ( |
@@ -72,8 +72,7 @@ |
||
| 72 | 72 | if ($match[0] == $marchToUpper) |
| 73 | 73 | { |
| 74 | 74 | return UTF8::strtolower($match[0], $this->encoding); |
| 75 | - } |
|
| 76 | - else |
|
| 75 | + } else |
|
| 77 | 76 | { |
| 78 | 77 | return $marchToUpper; |
| 79 | 78 | } |