| Conditions | 10 |
| Paths | 41 |
| Total Lines | 62 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php namespace CMPayments\JsonLint; |
||
| 153 | private function next() |
||
| 154 | { |
||
| 155 | if ($this->done) { |
||
| 156 | |||
| 157 | return $this->EOF; |
||
| 158 | } |
||
| 159 | |||
| 160 | if (!$this->input) { |
||
| 161 | |||
| 162 | $this->done = true; |
||
| 163 | } |
||
| 164 | |||
| 165 | $match = $lines = null; |
||
| 166 | |||
| 167 | $this->yText = $this->match = ''; |
||
| 168 | |||
| 169 | $rules = $this->getCurrentRules(); |
||
| 170 | $rulesLen = count($rules); |
||
| 171 | |||
| 172 | for ($i = 0; $i < $rulesLen; $i++) { |
||
| 173 | |||
| 174 | if (preg_match($this->rules[$rules[$i]], $this->input, $match)) { |
||
| 175 | |||
| 176 | preg_match_all('/\n.*/', $match[0], $lines); |
||
| 177 | $lines = $lines[0]; |
||
| 178 | |||
| 179 | if ($lines) { |
||
| 180 | |||
| 181 | $this->yLineNo += count($lines); |
||
| 182 | } |
||
| 183 | |||
| 184 | $this->yLocation = [ |
||
| 185 | 'last_line' => $this->yLineNo + 1, |
||
| 186 | 'last_column' => $lines ? strlen($lines[count($lines) - 1]) - 1 : $this->yLocation['last_column'] + strlen($match[0]), |
||
| 187 | ]; |
||
| 188 | |||
| 189 | preg_match("/^[\"|']?(?P<match>.*?)(?:[\"|'](.*)$|$)/", explode("\n", $this->input)[0], $inputMatches); |
||
| 190 | |||
| 191 | $this->yText .= $match[0]; |
||
| 192 | $this->match .= (isset($inputMatches['match']) ? $inputMatches['match'] : $match[0]); |
||
| 193 | $this->yLength = strlen($this->yText); |
||
| 194 | $this->yColumnNo = $this->yLocation['last_column']; |
||
| 195 | $this->input = substr($this->input, strlen($this->yText)); |
||
| 196 | $this->matched .= $this->yText; |
||
| 197 | $token = $this->performAction($rules[$i]); |
||
| 198 | |||
| 199 | if ($token) { |
||
| 200 | |||
| 201 | return $token; |
||
| 202 | } |
||
| 203 | |||
| 204 | return new UndefinedException(UndefinedException::ERROR_UNDEFINED_VALIDATION); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | if ($this->input === '') { |
||
| 209 | |||
| 210 | return $this->EOF; |
||
| 211 | } |
||
| 212 | |||
| 213 | throw new JsonLintException(JsonLintException::ERROR_LEXICAL_ERROR, [($this->yLineNo + 1)]); |
||
| 214 | } |
||
| 215 | |||
| 282 |