| Conditions | 36 |
| Paths | 3 |
| Total Lines | 124 |
| Code Lines | 104 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 143 | public function parse(): void |
||
| 144 | { |
||
| 145 | $java_recv_size = $this->handler->getParam('JAVA_RECV_SIZE'); |
||
| 146 | while ($this->eor == 0) { |
||
| 147 | if ($this->c >= $this->pos) { |
||
| 148 | $this->buf = $this->handler->read($java_recv_size); |
||
| 149 | if (null === $this->buf || strlen($this->buf) == 0) { |
||
| 150 | $this->handler->protocol->handler->shutdownBrokenConnection('protocol error. Check the back end log for OutOfMemoryErrors.'); |
||
| 151 | } |
||
| 152 | $this->pos = strlen($this->buf); |
||
| 153 | if ($this->pos == 0) { |
||
| 154 | break; |
||
| 155 | } |
||
| 156 | $this->c = 0; |
||
| 157 | } |
||
| 158 | switch (($ch = $this->buf[$this->c])) { |
||
| 159 | case '<': |
||
| 160 | if ($this->in_dquote) { |
||
| 161 | $this->APPEND($ch); |
||
| 162 | break; |
||
| 163 | } |
||
| 164 | ++$this->level; |
||
| 165 | $this->type = $this->BEGIN; |
||
| 166 | break; |
||
| 167 | case '\t': |
||
| 168 | case '\f': |
||
| 169 | case '\n': |
||
| 170 | case '\r': |
||
| 171 | case ' ': |
||
| 172 | if ($this->in_dquote) { |
||
| 173 | $this->APPEND($ch); |
||
| 174 | break; |
||
| 175 | } |
||
| 176 | if ($this->type == $this->BEGIN) { |
||
| 177 | $this->PUSH($this->type); |
||
| 178 | $this->type = $this->KEY; |
||
| 179 | } |
||
| 180 | break; |
||
| 181 | case '=': |
||
| 182 | if ($this->in_dquote) { |
||
| 183 | $this->APPEND($ch); |
||
| 184 | break; |
||
| 185 | } |
||
| 186 | $this->PUSH($this->type); |
||
| 187 | $this->type = $this->VAL; |
||
| 188 | break; |
||
| 189 | case '/': |
||
| 190 | if ($this->in_dquote) { |
||
| 191 | $this->APPEND($ch); |
||
| 192 | break; |
||
| 193 | } |
||
| 194 | if ($this->type == $this->BEGIN) { |
||
| 195 | $this->type = $this->END; |
||
| 196 | --$this->level; |
||
| 197 | } |
||
| 198 | --$this->level; |
||
| 199 | $this->eot = true; |
||
| 200 | break; |
||
| 201 | case '>': |
||
| 202 | if ($this->in_dquote) { |
||
| 203 | $this->APPEND($ch); |
||
| 204 | break; |
||
| 205 | } |
||
| 206 | if ($this->type == $this->END) { |
||
| 207 | $this->PUSH($this->BEGIN); |
||
| 208 | $this->CALL_END(); |
||
| 209 | } else { |
||
| 210 | if ($this->type == $this->VAL) { |
||
| 211 | $this->PUSH($this->type); |
||
| 212 | } |
||
| 213 | $this->CALL_BEGIN(); |
||
| 214 | } |
||
| 215 | $this->tag[0]->n = $this->tag[1]->n = $this->tag[2]->n = 0; |
||
| 216 | $this->i0 = $this->i = 0; |
||
| 217 | $this->type = $this->VOJD; |
||
| 218 | if ($this->level == 0) { |
||
| 219 | $this->eor = 1; |
||
| 220 | } |
||
| 221 | break; |
||
| 222 | case ';': |
||
| 223 | if ($this->type == $this->ENTITY) { |
||
| 224 | switch ($this->s[$this->e + 1]) { |
||
| 225 | case 'l': |
||
| 226 | $this->s[$this->e] = '<'; |
||
| 227 | $this->i = $this->e + 1; |
||
| 228 | break; |
||
| 229 | case 'g': |
||
| 230 | $this->s[$this->e] = '>'; |
||
| 231 | $this->i = $this->e + 1; |
||
| 232 | break; |
||
| 233 | case 'a': |
||
| 234 | $this->s[$this->e] = ($this->s[$this->e + 2] == 'm' ? '&' : '\''); |
||
| 235 | $this->i = $this->e + 1; |
||
| 236 | break; |
||
| 237 | case 'q': |
||
| 238 | $this->s[$this->e] = '"'; |
||
| 239 | $this->i = $this->e + 1; |
||
| 240 | break; |
||
| 241 | default: |
||
| 242 | $this->APPEND($ch); |
||
| 243 | } |
||
| 244 | $this->type = $this->VAL; |
||
| 245 | } else { |
||
| 246 | $this->APPEND($ch); |
||
| 247 | } |
||
| 248 | break; |
||
| 249 | case '&': |
||
| 250 | $this->type = $this->ENTITY; |
||
| 251 | $this->e = $this->i; |
||
| 252 | $this->APPEND($ch); |
||
| 253 | break; |
||
| 254 | case '"': |
||
| 255 | $this->in_dquote = !$this->in_dquote; |
||
| 256 | if (!$this->in_dquote && $this->type == $this->VAL) { |
||
| 257 | $this->PUSH($this->type); |
||
| 258 | $this->type = $this->KEY; |
||
| 259 | } |
||
| 260 | break; |
||
| 261 | default: |
||
| 262 | $this->APPEND($ch); |
||
| 263 | } |
||
| 264 | ++$this->c; |
||
| 265 | } |
||
| 266 | $this->RESET(); |
||
| 267 | } |
||
| 274 |