| @@ -15,8 +15,7 @@ | ||
| 15 | 15 |  { | 
| 16 | 16 | public function __construct() | 
| 17 | 17 |      { | 
| 18 | - parent::__construct | |
| 19 | - ( | |
| 18 | + parent::__construct( | |
| 20 | 19 | 'You can not append a string of a different encoding '. | 
| 21 | 20 | 'to that of the existing string!' | 
| 22 | 21 | ); | 
| @@ -232,16 +232,14 @@ | ||
| 232 | 232 | */ | 
| 233 | 233 | public function remove($startIndex, $length) | 
| 234 | 234 |      { | 
| 235 | - $start = UTF8::substr | |
| 236 | - ( | |
| 235 | + $start = UTF8::substr( | |
| 237 | 236 | (string)$this->str, | 
| 238 | 237 | 0, | 
| 239 | 238 | $startIndex, | 
| 240 | 239 | $this->str->getEncoding() | 
| 241 | 240 | ); | 
| 242 | 241 | |
| 243 | - $end = UTF8::substr | |
| 244 | - ( | |
| 242 | + $end = UTF8::substr( | |
| 245 | 243 | (string)$this->str, | 
| 246 | 244 | $startIndex + $length, | 
| 247 | 245 | $this->str->getLength(), | 
| @@ -29,8 +29,7 @@ discard block | ||
| 29 | 29 | */ | 
| 30 | 30 | public function startsWith($substring, $caseSensitive = true) | 
| 31 | 31 |      { | 
| 32 | - $startOfStr = UTF8::substr | |
| 33 | - ( | |
| 32 | + $startOfStr = UTF8::substr( | |
| 34 | 33 | $this->scalarString, | 
| 35 | 34 | 0, | 
| 36 | 35 | UTF8::strlen($substring, $this->encoding), | 
| @@ -60,8 +59,7 @@ discard block | ||
| 60 | 59 |      { | 
| 61 | 60 | $substringLength = UTF8::strlen($substring, $this->encoding); | 
| 62 | 61 | |
| 63 | - $endOfStr = UTF8::substr | |
| 64 | - ( | |
| 62 | + $endOfStr = UTF8::substr( | |
| 65 | 63 | $this->scalarString, | 
| 66 | 64 | $this->getLength() - $substringLength, | 
| 67 | 65 | $substringLength, | 
| @@ -66,16 +66,14 @@ discard block | ||
| 66 | 66 |      { | 
| 67 | 67 | if ($index > $this->getLength()) throw new \OutOfBoundsException(); | 
| 68 | 68 | |
| 69 | - $start = UTF8::substr | |
| 70 | - ( | |
| 69 | + $start = UTF8::substr( | |
| 71 | 70 | $this->scalarString, | 
| 72 | 71 | 0, | 
| 73 | 72 | $index, | 
| 74 | 73 | $this->encoding | 
| 75 | 74 | ); | 
| 76 | 75 | |
| 77 | - $end = UTF8::substr | |
| 78 | - ( | |
| 76 | + $end = UTF8::substr( | |
| 79 | 77 | $this->scalarString, | 
| 80 | 78 | $index, | 
| 81 | 79 | $this->getLength(), | 
| @@ -104,8 +102,7 @@ discard block | ||
| 104 | 102 | */ | 
| 105 | 103 | public function repeat($multiplier) | 
| 106 | 104 |      { | 
| 107 | - return $this->newSelf | |
| 108 | - ( | |
| 105 | + return $this->newSelf( | |
| 109 | 106 | UTF8::str_repeat($this->scalarString, $multiplier) | 
| 110 | 107 | ); | 
| 111 | 108 | } | 
| @@ -163,8 +160,7 @@ discard block | ||
| 163 | 160 | $length = $end - $start; | 
| 164 | 161 | } | 
| 165 | 162 | |
| 166 | - return $this->newSelf | |
| 167 | - ( | |
| 163 | + return $this->newSelf( | |
| 168 | 164 | UTF8::substr($this->scalarString, $start, $length, $this->encoding) | 
| 169 | 165 | ); | 
| 170 | 166 | } | 
| @@ -179,8 +175,7 @@ discard block | ||
| 179 | 175 | */ | 
| 180 | 176 | public function surround($substring) | 
| 181 | 177 |      { | 
| 182 | - return $this->newSelf | |
| 183 | - ( | |
| 178 | + return $this->newSelf( | |
| 184 | 179 |              implode('', [$substring, $this->scalarString, $substring]) | 
| 185 | 180 | ); | 
| 186 | 181 | } | 
| @@ -213,8 +208,7 @@ discard block | ||
| 213 | 208 |      { | 
| 214 | 209 | if ($caseSensitive) | 
| 215 | 210 |          { | 
| 216 | - return UTF8::substr_count | |
| 217 | - ( | |
| 211 | + return UTF8::substr_count( | |
| 218 | 212 | $this->scalarString, | 
| 219 | 213 | $substring, | 
| 220 | 214 | $this->encoding | 
| @@ -64,7 +64,10 @@ | ||
| 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 | +        { | |
| 69 | + throw new \OutOfBoundsException(); | |
| 70 | + } | |
| 68 | 71 | |
| 69 | 72 | $start = UTF8::substr | 
| 70 | 73 | ( | 
| @@ -42,8 +42,7 @@ | ||
| 42 | 42 | $endIndex = $this->indexOf($end, $substrIndex); | 
| 43 | 43 |          if ($endIndex === false) return $this->newSelf(''); | 
| 44 | 44 | |
| 45 | - $result = UTF8::substr | |
| 46 | - ( | |
| 45 | + $result = UTF8::substr( | |
| 47 | 46 | $this->scalarString, | 
| 48 | 47 | $substrIndex, | 
| 49 | 48 | $endIndex - $substrIndex, | 
| @@ -35,12 +35,18 @@ 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 | +        { | |
| 40 | +            return $this->newSelf(''); | |
| 41 | + } | |
| 39 | 42 | |
| 40 | 43 | $substrIndex = $startIndex + UTF8::strlen($start, $this->encoding); | 
| 41 | 44 | |
| 42 | 45 | $endIndex = $this->indexOf($end, $substrIndex); | 
| 43 | -        if ($endIndex === false) return $this->newSelf(''); | |
| 46 | + if ($endIndex === false) | |
| 47 | +        { | |
| 48 | +            return $this->newSelf(''); | |
| 49 | + } | |
| 44 | 50 | |
| 45 | 51 | $result = UTF8::substr | 
| 46 | 52 | ( | 
| @@ -50,7 +56,10 @@ discard block | ||
| 50 | 56 | $this->encoding | 
| 51 | 57 | ); | 
| 52 | 58 | |
| 53 | - if ($include === true) $result = $start.$result.$end; | |
| 59 | + if ($include === true) | |
| 60 | +        { | |
| 61 | + $result = $start.$result.$end; | |
| 62 | + } | |
| 54 | 63 | |
| 55 | 64 | return $this->newSelf($result); | 
| 56 | 65 | } | 
| @@ -28,8 +28,7 @@ discard block | ||
| 28 | 28 | |
| 29 | 29 | if ($n > 0) | 
| 30 | 30 |          { | 
| 31 | - $first = UTF8::substr | |
| 32 | - ( | |
| 31 | + $first = UTF8::substr( | |
| 33 | 32 | $this->scalarString, | 
| 34 | 33 | 0, | 
| 35 | 34 | $n, | 
| @@ -53,8 +52,7 @@ discard block | ||
| 53 | 52 | |
| 54 | 53 | if ($n > 0) | 
| 55 | 54 |          { | 
| 56 | - $last = UTF8::substr | |
| 57 | - ( | |
| 55 | + $last = UTF8::substr( | |
| 58 | 56 | $this->scalarString, | 
| 59 | 57 | -$n, | 
| 60 | 58 | null, | 
| @@ -26,10 +26,8 @@ discard block | ||
| 26 | 26 |      { | 
| 27 | 27 | if ($this->startsWith($substring)) | 
| 28 | 28 |          { | 
| 29 | - return $this->newSelf | |
| 30 | - ( | |
| 31 | - UTF8::substr | |
| 32 | - ( | |
| 29 | + return $this->newSelf( | |
| 30 | + UTF8::substr( | |
| 33 | 31 | $this->scalarString, | 
| 34 | 32 | UTF8::strlen($substring, $this->encoding), | 
| 35 | 33 | null, | 
| @@ -52,10 +50,8 @@ discard block | ||
| 52 | 50 |      { | 
| 53 | 51 | if ($this->endsWith($substring)) | 
| 54 | 52 |          { | 
| 55 | - return $this->newSelf | |
| 56 | - ( | |
| 57 | - UTF8::substr | |
| 58 | - ( | |
| 53 | + return $this->newSelf( | |
| 54 | + UTF8::substr( | |
| 59 | 55 | $this->scalarString, | 
| 60 | 56 | 0, | 
| 61 | 57 | $this->getLength() - UTF8::strlen($substring, $this->encoding), | 
| @@ -36,15 +36,14 @@ discard block | ||
| 36 | 36 | $substringLength = UTF8::strlen($substring, $this->encoding); | 
| 37 | 37 | $length -= $substringLength; | 
| 38 | 38 | |
| 39 | - $truncated = UTF8::substr | |
| 40 | - ( | |
| 39 | + $truncated = UTF8::substr( | |
| 41 | 40 | $this->scalarString, | 
| 42 | 41 | 0, | 
| 43 | 42 | $length, | 
| 44 | 43 | $this->encoding | 
| 45 | 44 | ); | 
| 46 | 45 | |
| 47 | - return $this->newSelf($truncated . $substring); | |
| 46 | + return $this->newSelf($truncated.$substring); | |
| 48 | 47 | } | 
| 49 | 48 | |
| 50 | 49 | /** | 
| @@ -79,6 +78,6 @@ discard block | ||
| 79 | 78 | $truncated = UTF8::substr($truncated, 0, $lastPos, $this->encoding); | 
| 80 | 79 | } | 
| 81 | 80 | |
| 82 | - return $this->newSelf($truncated . $substring); | |
| 81 | + return $this->newSelf($truncated.$substring); | |
| 83 | 82 | } | 
| 84 | 83 | } | 
| @@ -30,7 +30,10 @@ 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 | +        { | |
| 35 | + return $this; | |
| 36 | + } | |
| 34 | 37 | |
| 35 | 38 | // Need to further trim the string so we can append the substring | 
| 36 | 39 | $substringLength = UTF8::strlen($substring, $this->encoding); | 
| @@ -63,7 +66,10 @@ discard block | ||
| 63 | 66 | */ | 
| 64 | 67 | public function safeTruncate($length, $substring = '') | 
| 65 | 68 |      { | 
| 66 | - if ($length >= $this->getLength()) return $this; | |
| 69 | + if ($length >= $this->getLength()) | |
| 70 | +        { | |
| 71 | + return $this; | |
| 72 | + } | |
| 67 | 73 | |
| 68 | 74 | // Need to further trim the string so we can append the substring | 
| 69 | 75 | $substringLength = UTF8::strlen($substring, $this->encoding); | 
| @@ -76,7 +82,10 @@ discard block | ||
| 76 | 82 |          { | 
| 77 | 83 | // Find pos of the last occurrence of a space, get up to that | 
| 78 | 84 | $lastPos = UTF8::strrpos($truncated, ' ', 0, $this->encoding); | 
| 79 | - if (!is_integer($lastPos)) $lastPos = 0; | |
| 85 | + if (!is_integer($lastPos)) | |
| 86 | +            { | |
| 87 | + $lastPos = 0; | |
| 88 | + } | |
| 80 | 89 | $truncated = UTF8::substr($truncated, 0, $lastPos, $this->encoding); | 
| 81 | 90 | } | 
| 82 | 91 | |
| @@ -37,8 +37,7 @@ discard block | ||
| 37 | 37 |      { | 
| 38 | 38 | if (!in_array($padType, ['left', 'right', 'both'], true)) | 
| 39 | 39 |          { | 
| 40 | - throw new \InvalidArgumentException | |
| 41 | - ( | |
| 40 | + throw new \InvalidArgumentException( | |
| 42 | 41 | 'Pad expects $padType '."to be one of 'left', 'right' or 'both'" | 
| 43 | 42 | ); | 
| 44 | 43 | } | 
| @@ -118,16 +117,14 @@ discard block | ||
| 118 | 117 | |
| 119 | 118 | if (!$length || $paddedLength <= $strLength) return $this; | 
| 120 | 119 | |
| 121 | - $leftPadding = UTF8::substr | |
| 122 | - ( | |
| 120 | + $leftPadding = UTF8::substr( | |
| 123 | 121 | UTF8::str_repeat($padStr, ceil($left / $length)), | 
| 124 | 122 | 0, | 
| 125 | 123 | $left, | 
| 126 | 124 | $this->encoding | 
| 127 | 125 | ); | 
| 128 | 126 | |
| 129 | - $rightPadding = UTF8::substr | |
| 130 | - ( | |
| 127 | + $rightPadding = UTF8::substr( | |
| 131 | 128 | UTF8::str_repeat($padStr, ceil($right / $length)), | 
| 132 | 129 | 0, | 
| 133 | 130 | $right, | 
| @@ -116,7 +116,10 @@ | ||
| 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 | +        { | |
| 121 | + return $this; | |
| 122 | + } | |
| 120 | 123 | |
| 121 | 124 | $leftPadding = UTF8::substr | 
| 122 | 125 | ( |