@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -88,7 +88,10 @@ |
||
88 | 88 | $otherLength = UTF8::strlen($otherStr, $this->encoding); |
89 | 89 | |
90 | 90 | // Return if either string is empty |
91 | - if ($strLength == 0 || $otherLength == 0) return $this->newSelf(''); |
|
91 | + if ($strLength == 0 || $otherLength == 0) |
|
92 | + { |
|
93 | + return $this->newSelf(''); |
|
94 | + } |
|
92 | 95 | |
93 | 96 | $len = 0; $end = 0; |
94 | 97 | $table = array_fill(0, $strLength + 1, array_fill(0, $otherLength + 1, 0)); |
@@ -53,11 +53,17 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function containsAll($needles, $caseSensitive = true) |
55 | 55 | { |
56 | - if (empty($needles)) return false; |
|
56 | + if (empty($needles)) |
|
57 | + { |
|
58 | + return false; |
|
59 | + } |
|
57 | 60 | |
58 | 61 | foreach ($needles as $needle) |
59 | 62 | { |
60 | - if (!$this->contains($needle, $caseSensitive)) return false; |
|
63 | + if (!$this->contains($needle, $caseSensitive)) |
|
64 | + { |
|
65 | + return false; |
|
66 | + } |
|
61 | 67 | } |
62 | 68 | |
63 | 69 | return true; |
@@ -77,11 +83,17 @@ discard block |
||
77 | 83 | */ |
78 | 84 | public function containsAny($needles, $caseSensitive = true) |
79 | 85 | { |
80 | - if (empty($needles)) return false; |
|
86 | + if (empty($needles)) |
|
87 | + { |
|
88 | + return false; |
|
89 | + } |
|
81 | 90 | |
82 | 91 | foreach ($needles as $needle) |
83 | 92 | { |
84 | - if ($this->contains($needle, $caseSensitive)) return true; |
|
93 | + if ($this->contains($needle, $caseSensitive)) |
|
94 | + { |
|
95 | + return true; |
|
96 | + } |
|
85 | 97 | } |
86 | 98 | |
87 | 99 | return false; |