@@ -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" |
@@ -100,8 +100,7 @@ discard block |
||
| 100 | 100 | ( |
| 101 | 101 | 'Passed value cannot be an array' |
| 102 | 102 | ); |
| 103 | - } |
|
| 104 | - elseif (is_object($string) && !method_exists($string, '__toString')) |
|
| 103 | + } elseif (is_object($string) && !method_exists($string, '__toString')) |
|
| 105 | 104 | { |
| 106 | 105 | throw new \InvalidArgumentException |
| 107 | 106 | ( |
@@ -119,8 +118,7 @@ discard block |
||
| 119 | 118 | if ($encoding !== null) |
| 120 | 119 | { |
| 121 | 120 | $this->encoding = $encoding; |
| 122 | - } |
|
| 123 | - else |
|
| 121 | + } else |
|
| 124 | 122 | { |
| 125 | 123 | $this->encoding = mb_internal_encoding(); |
| 126 | 124 | } |
@@ -199,13 +197,11 @@ discard block |
||
| 199 | 197 | { |
| 200 | 198 | // Convert the scalar string to a Str Object |
| 201 | 199 | $strObjects[$key] = $this->newSelf($value); |
| 202 | - } |
|
| 203 | - elseif (is_array($value)) |
|
| 200 | + } elseif (is_array($value)) |
|
| 204 | 201 | { |
| 205 | 202 | // Recurse into the array |
| 206 | 203 | $strObjects[$key] = $this->newSelfs($value); |
| 207 | - } |
|
| 208 | - else |
|
| 204 | + } else |
|
| 209 | 205 | { |
| 210 | 206 | // We don't know what it is do do nothing to it |
| 211 | 207 | $strObjects[$key] = $value; |
@@ -259,7 +255,9 @@ discard block |
||
| 259 | 255 | { |
| 260 | 256 | $index = (int)$index; |
| 261 | 257 | |
| 262 | - if ($index >= 0) return ($this->getLength() > $index); |
|
| 258 | + if ($index >= 0) { |
|
| 259 | + return ($this->getLength() > $index); |
|
| 260 | + } |
|
| 263 | 261 | |
| 264 | 262 | return ($this->getLength() >= abs($index)); |
| 265 | 263 | } |
@@ -88,7 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function isJson() |
| 90 | 90 | { |
| 91 | - if ($this->getLength() === 0) return false; |
|
| 91 | + if ($this->getLength() === 0) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 92 | 94 | |
| 93 | 95 | json_decode($this->scalarString); |
| 94 | 96 | |
@@ -102,7 +104,9 @@ discard block |
||
| 102 | 104 | */ |
| 103 | 105 | public function isSerialized() |
| 104 | 106 | { |
| 105 | - if ($this->getLength() === 0) return false; |
|
| 107 | + if ($this->getLength() === 0) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
| 108 | 112 | return |
@@ -120,7 +124,9 @@ discard block |
||
| 120 | 124 | public function isBase64() |
| 121 | 125 | { |
| 122 | 126 | // An empty string is by definition not encoded. |
| 123 | - if ($this->getLength() === 0) return false; |
|
| 127 | + if ($this->getLength() === 0) { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 124 | 130 | |
| 125 | 131 | // Grab the current string value. |
| 126 | 132 | $possiblyEncoded = $this->scalarString; |
@@ -129,7 +135,9 @@ discard block |
||
| 129 | 135 | $decoded = base64_decode($possiblyEncoded, true); |
| 130 | 136 | |
| 131 | 137 | // If we get false it can't be base64 |
| 132 | - if ($decoded === false) return false; |
|
| 138 | + if ($decoded === false) { |
|
| 139 | + return false; |
|
| 140 | + } |
|
| 133 | 141 | |
| 134 | 142 | // Lets double check |
| 135 | 143 | return (base64_encode($decoded) === $this->scalarString); |
@@ -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 | } |
@@ -72,8 +72,7 @@ |
||
| 72 | 72 | if (!$chars) |
| 73 | 73 | { |
| 74 | 74 | return '[:space:]'; |
| 75 | - } |
|
| 76 | - else |
|
| 75 | + } else |
|
| 77 | 76 | { |
| 78 | 77 | return preg_quote($chars, $this->regexDelimiter); |
| 79 | 78 | } |
@@ -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 | { |