@@ -259,7 +259,10 @@ |
||
259 | 259 | { |
260 | 260 | $index = (int)$index; |
261 | 261 | |
262 | - if ($index >= 0) return ($this->getLength() > $index); |
|
262 | + if ($index >= 0) |
|
263 | + { |
|
264 | + return ($this->getLength() > $index); |
|
265 | + } |
|
263 | 266 | |
264 | 267 | return ($this->getLength() >= abs($index)); |
265 | 268 | } |
@@ -71,8 +71,14 @@ |
||
71 | 71 | */ |
72 | 72 | public function replaceExact($search, $replacement) |
73 | 73 | { |
74 | - if (!is_array($search)) $search = [$search]; |
|
75 | - if (!is_array($replacement)) $replacement = [$replacement]; |
|
74 | + if (!is_array($search)) |
|
75 | + { |
|
76 | + $search = [$search]; |
|
77 | + } |
|
78 | + if (!is_array($replacement)) |
|
79 | + { |
|
80 | + $replacement = [$replacement]; |
|
81 | + } |
|
76 | 82 | |
77 | 83 | if (count($search) !== count($replacement)) |
78 | 84 | { |
@@ -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 | } |
@@ -88,7 +88,10 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function isJson() |
90 | 90 | { |
91 | - if ($this->getLength() === 0) return false; |
|
91 | + if ($this->getLength() === 0) |
|
92 | + { |
|
93 | + return false; |
|
94 | + } |
|
92 | 95 | |
93 | 96 | json_decode($this->scalarString); |
94 | 97 | |
@@ -102,7 +105,10 @@ discard block |
||
102 | 105 | */ |
103 | 106 | public function isSerialized() |
104 | 107 | { |
105 | - if ($this->getLength() === 0) return false; |
|
108 | + if ($this->getLength() === 0) |
|
109 | + { |
|
110 | + return false; |
|
111 | + } |
|
106 | 112 | |
107 | 113 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
108 | 114 | return |
@@ -120,7 +126,10 @@ discard block |
||
120 | 126 | public function isBase64() |
121 | 127 | { |
122 | 128 | // An empty string is by definition not encoded. |
123 | - if ($this->getLength() === 0) return false; |
|
129 | + if ($this->getLength() === 0) |
|
130 | + { |
|
131 | + return false; |
|
132 | + } |
|
124 | 133 | |
125 | 134 | // Grab the current string value. |
126 | 135 | $possiblyEncoded = $this->scalarString; |
@@ -129,7 +138,10 @@ discard block |
||
129 | 138 | $decoded = base64_decode($possiblyEncoded, true); |
130 | 139 | |
131 | 140 | // If we get false it can't be base64 |
132 | - if ($decoded === false) return false; |
|
141 | + if ($decoded === false) |
|
142 | + { |
|
143 | + return false; |
|
144 | + } |
|
133 | 145 | |
134 | 146 | // Lets double check |
135 | 147 | return (base64_encode($decoded) === $this->scalarString); |
@@ -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 | ( |
@@ -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 | ( |
@@ -53,7 +53,10 @@ discard block |
||
53 | 53 | public function regexMatch($pattern, $options = '') |
54 | 54 | { |
55 | 55 | // Ensure the options contain the "u" modifier. |
56 | - if (!$this->newSelf($options)->contains('u')) $options .= 'u'; |
|
56 | + if (!$this->newSelf($options)->contains('u')) |
|
57 | + { |
|
58 | + $options .= 'u'; |
|
59 | + } |
|
57 | 60 | |
58 | 61 | // Build the expression |
59 | 62 | $expression = |
@@ -67,7 +70,10 @@ discard block |
||
67 | 70 | $result = preg_match($expression, $this->scalarString); |
68 | 71 | |
69 | 72 | // If no errors return true or false based on number of matches found. |
70 | - if ($result !== false) return $result === 1; |
|
73 | + if ($result !== false) |
|
74 | + { |
|
75 | + return $result === 1; |
|
76 | + } |
|
71 | 77 | |
72 | 78 | // Otherwise throw with last known PCRE Error. |
73 | 79 | throw new PcreException(); |
@@ -94,7 +100,10 @@ discard block |
||
94 | 100 | $matches = []; |
95 | 101 | |
96 | 102 | // Ensure the options contain the "u" modifier. |
97 | - if (!$this->newSelf($options)->contains('u')) $options .= 'u'; |
|
103 | + if (!$this->newSelf($options)->contains('u')) |
|
104 | + { |
|
105 | + $options .= 'u'; |
|
106 | + } |
|
98 | 107 | |
99 | 108 | // Build the expression |
100 | 109 | $expression = |
@@ -108,7 +117,10 @@ discard block |
||
108 | 117 | $result = preg_match($expression, $this->scalarString, $matches); |
109 | 118 | |
110 | 119 | // If no errors return the $matches array |
111 | - if ($result !== false) return $this->newSelfs($matches); |
|
120 | + if ($result !== false) |
|
121 | + { |
|
122 | + return $this->newSelfs($matches); |
|
123 | + } |
|
112 | 124 | |
113 | 125 | // Otherwise throw with last known PCRE Error. |
114 | 126 | throw new PcreException(); |
@@ -131,10 +143,16 @@ discard block |
||
131 | 143 | { |
132 | 144 | // The original regexReplace method in danielstjules/Stringy used |
133 | 145 | // mb_ereg_replace() which supports an "r" flag, PCRE does not. |
134 | - if ($options === 'msr') $options = 'ms'; |
|
146 | + if ($options === 'msr') |
|
147 | + { |
|
148 | + $options = 'ms'; |
|
149 | + } |
|
135 | 150 | |
136 | 151 | // Ensure the options contain the "u" modifier. |
137 | - if (!$this->newSelf($options)->contains('u')) $options .= 'u'; |
|
152 | + if (!$this->newSelf($options)->contains('u')) |
|
153 | + { |
|
154 | + $options .= 'u'; |
|
155 | + } |
|
138 | 156 | |
139 | 157 | // Build the expression |
140 | 158 | $expression = |
@@ -148,7 +166,10 @@ discard block |
||
148 | 166 | $replaced = preg_replace($expression, $replacement, $this->scalarString); |
149 | 167 | |
150 | 168 | // If no errors return the replacement |
151 | - if ($replaced !== null) return $this->newSelf($replaced); |
|
169 | + if ($replaced !== null) |
|
170 | + { |
|
171 | + return $this->newSelf($replaced); |
|
172 | + } |
|
152 | 173 | |
153 | 174 | // Otherwise throw with last known PCRE Error. |
154 | 175 | throw new PcreException(); |
@@ -170,11 +191,17 @@ discard block |
||
170 | 191 | public function split($pattern, $limit = null, $quote = true) |
171 | 192 | { |
172 | 193 | // Not sure why you would do this but your wish is our command :) |
173 | - if ($limit === 0) return []; |
|
194 | + if ($limit === 0) |
|
195 | + { |
|
196 | + return []; |
|
197 | + } |
|
174 | 198 | |
175 | 199 | // UTF8::split errors when supplied an empty pattern in < PHP 5.4.13 |
176 | 200 | // and current versions of HHVM (3.8 and below) |
177 | - if ($pattern === '') return [$this->newSelf($this->scalarString)]; |
|
201 | + if ($pattern === '') |
|
202 | + { |
|
203 | + return [$this->newSelf($this->scalarString)]; |
|
204 | + } |
|
178 | 205 | |
179 | 206 | // UTF8::split returns the remaining unsplit string |
180 | 207 | // in the last index when supplying a limit. |
@@ -208,7 +235,10 @@ discard block |
||
208 | 235 | $array = preg_split($expression, $this->scalarString, $limit); |
209 | 236 | |
210 | 237 | // Remove any remaining unsplit string. |
211 | - if ($limit > 0 && count($array) === $limit) array_pop($array); |
|
238 | + if ($limit > 0 && count($array) === $limit) |
|
239 | + { |
|
240 | + array_pop($array); |
|
241 | + } |
|
212 | 242 | |
213 | 243 | return $this->newSelfs($array); |
214 | 244 | } |
@@ -52,7 +52,10 @@ |
||
52 | 52 | */ |
53 | 53 | public function htmlEncode($flags = null, $doubleEncode = true) |
54 | 54 | { |
55 | - if ($flags === null) $flags = ENT_QUOTES | ENT_SUBSTITUTE; |
|
55 | + if ($flags === null) |
|
56 | + { |
|
57 | + $flags = ENT_QUOTES | ENT_SUBSTITUTE; |
|
58 | + } |
|
56 | 59 | |
57 | 60 | return $this->newSelf |
58 | 61 | ( |
@@ -292,7 +292,10 @@ |
||
292 | 292 | |
293 | 293 | $camelCase = $this->newSelf($camelCase); |
294 | 294 | |
295 | - if ($upperFirst === true) $camelCase = $camelCase->upperCaseFirst(); |
|
295 | + if ($upperFirst === true) |
|
296 | + { |
|
297 | + $camelCase = $camelCase->upperCaseFirst(); |
|
298 | + } |
|
296 | 299 | |
297 | 300 | return $camelCase; |
298 | 301 | } |