@@ -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 | ( |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | if ($caseSensitive) |
33 | 33 | { |
34 | 34 | return (UTF8::strpos($this->scalarString, $needle, 0, $this->encoding) !== false); |
35 | - } |
|
36 | - else |
|
35 | + } else |
|
37 | 36 | { |
38 | 37 | return (UTF8::stripos($this->scalarString, $needle, 0, $this->encoding) !== false); |
39 | 38 | } |
@@ -53,11 +52,15 @@ discard block |
||
53 | 52 | */ |
54 | 53 | public function containsAll($needles, $caseSensitive = true) |
55 | 54 | { |
56 | - if (empty($needles)) return false; |
|
55 | + if (empty($needles)) { |
|
56 | + return false; |
|
57 | + } |
|
57 | 58 | |
58 | 59 | foreach ($needles as $needle) |
59 | 60 | { |
60 | - if (!$this->contains($needle, $caseSensitive)) return false; |
|
61 | + if (!$this->contains($needle, $caseSensitive)) { |
|
62 | + return false; |
|
63 | + } |
|
61 | 64 | } |
62 | 65 | |
63 | 66 | return true; |
@@ -77,11 +80,15 @@ discard block |
||
77 | 80 | */ |
78 | 81 | public function containsAny($needles, $caseSensitive = true) |
79 | 82 | { |
80 | - if (empty($needles)) return false; |
|
83 | + if (empty($needles)) { |
|
84 | + return false; |
|
85 | + } |
|
81 | 86 | |
82 | 87 | foreach ($needles as $needle) |
83 | 88 | { |
84 | - if ($this->contains($needle, $caseSensitive)) return true; |
|
89 | + if ($this->contains($needle, $caseSensitive)) { |
|
90 | + return true; |
|
91 | + } |
|
85 | 92 | } |
86 | 93 | |
87 | 94 | return false; |
@@ -53,7 +53,9 @@ 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 | + $options .= 'u'; |
|
58 | + } |
|
57 | 59 | |
58 | 60 | // Build the expression |
59 | 61 | $expression = |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | $result = preg_match($expression, $this->scalarString); |
68 | 70 | |
69 | 71 | // If no errors return true or false based on number of matches found. |
70 | - if ($result !== false) return $result === 1; |
|
72 | + if ($result !== false) { |
|
73 | + return $result === 1; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | // Otherwise throw with last known PCRE Error. |
73 | 77 | throw new PcreException(); |
@@ -94,7 +98,9 @@ discard block |
||
94 | 98 | $matches = []; |
95 | 99 | |
96 | 100 | // Ensure the options contain the "u" modifier. |
97 | - if (!$this->newSelf($options)->contains('u')) $options .= 'u'; |
|
101 | + if (!$this->newSelf($options)->contains('u')) { |
|
102 | + $options .= 'u'; |
|
103 | + } |
|
98 | 104 | |
99 | 105 | // Build the expression |
100 | 106 | $expression = |
@@ -108,7 +114,9 @@ discard block |
||
108 | 114 | $result = preg_match($expression, $this->scalarString, $matches); |
109 | 115 | |
110 | 116 | // If no errors return the $matches array |
111 | - if ($result !== false) return $this->newSelfs($matches); |
|
117 | + if ($result !== false) { |
|
118 | + return $this->newSelfs($matches); |
|
119 | + } |
|
112 | 120 | |
113 | 121 | // Otherwise throw with last known PCRE Error. |
114 | 122 | throw new PcreException(); |
@@ -131,10 +139,14 @@ discard block |
||
131 | 139 | { |
132 | 140 | // The original regexReplace method in danielstjules/Stringy used |
133 | 141 | // mb_ereg_replace() which supports an "r" flag, PCRE does not. |
134 | - if ($options === 'msr') $options = 'ms'; |
|
142 | + if ($options === 'msr') { |
|
143 | + $options = 'ms'; |
|
144 | + } |
|
135 | 145 | |
136 | 146 | // Ensure the options contain the "u" modifier. |
137 | - if (!$this->newSelf($options)->contains('u')) $options .= 'u'; |
|
147 | + if (!$this->newSelf($options)->contains('u')) { |
|
148 | + $options .= 'u'; |
|
149 | + } |
|
138 | 150 | |
139 | 151 | // Build the expression |
140 | 152 | $expression = |
@@ -148,7 +160,9 @@ discard block |
||
148 | 160 | $replaced = preg_replace($expression, $replacement, $this->scalarString); |
149 | 161 | |
150 | 162 | // If no errors return the replacement |
151 | - if ($replaced !== null) return $this->newSelf($replaced); |
|
163 | + if ($replaced !== null) { |
|
164 | + return $this->newSelf($replaced); |
|
165 | + } |
|
152 | 166 | |
153 | 167 | // Otherwise throw with last known PCRE Error. |
154 | 168 | throw new PcreException(); |
@@ -170,19 +184,22 @@ discard block |
||
170 | 184 | public function split($pattern, $limit = null, $quote = true) |
171 | 185 | { |
172 | 186 | // Not sure why you would do this but your wish is our command :) |
173 | - if ($limit === 0) return []; |
|
187 | + if ($limit === 0) { |
|
188 | + return []; |
|
189 | + } |
|
174 | 190 | |
175 | 191 | // UTF8::split errors when supplied an empty pattern in < PHP 5.4.13 |
176 | 192 | // and current versions of HHVM (3.8 and below) |
177 | - if ($pattern === '') return [$this->newSelf($this->scalarString)]; |
|
193 | + if ($pattern === '') { |
|
194 | + return [$this->newSelf($this->scalarString)]; |
|
195 | + } |
|
178 | 196 | |
179 | 197 | // UTF8::split returns the remaining unsplit string |
180 | 198 | // in the last index when supplying a limit. |
181 | 199 | if ($limit > 0) |
182 | 200 | { |
183 | 201 | $limit += 1; |
184 | - } |
|
185 | - else |
|
202 | + } else |
|
186 | 203 | { |
187 | 204 | $limit = -1; |
188 | 205 | } |
@@ -196,8 +213,7 @@ discard block |
||
196 | 213 | if ($quote === true) |
197 | 214 | { |
198 | 215 | $expression .= preg_quote($pattern, $this->regexDelimiter); |
199 | - } |
|
200 | - else |
|
216 | + } else |
|
201 | 217 | { |
202 | 218 | $expression .= $pattern; |
203 | 219 | } |
@@ -208,7 +224,9 @@ discard block |
||
208 | 224 | $array = preg_split($expression, $this->scalarString, $limit); |
209 | 225 | |
210 | 226 | // Remove any remaining unsplit string. |
211 | - if ($limit > 0 && count($array) === $limit) array_pop($array); |
|
227 | + if ($limit > 0 && count($array) === $limit) { |
|
228 | + array_pop($array); |
|
229 | + } |
|
212 | 230 | |
213 | 231 | return $this->newSelfs($array); |
214 | 232 | } |
@@ -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 | } |
@@ -52,7 +52,9 @@ discard block |
||
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 | + $flags = ENT_QUOTES | ENT_SUBSTITUTE; |
|
57 | + } |
|
56 | 58 | |
57 | 59 | return $this->newSelf |
58 | 60 | ( |
@@ -94,8 +96,7 @@ discard block |
||
94 | 96 | if (class_exists('\\voku\\helper\\AntiXSS')) |
95 | 97 | { |
96 | 98 | $antiXss = new \voku\helper\AntiXSS(); |
97 | - } |
|
98 | - else |
|
99 | + } else |
|
99 | 100 | { |
100 | 101 | throw new \RuntimeException |
101 | 102 | ( |