Conditions | 12 |
Paths | 27 |
Total Lines | 48 |
Code Lines | 35 |
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 |
||
54 | public function inbound(string $recv, Nsqd $nsqd, Closure $waiter, Consuming $consuming = null) : void |
||
55 | { |
||
56 | $this->buffer->write($recv); |
||
57 | |||
58 | PARSE_LOOP: |
||
59 | |||
60 | switch ($this->state) { |
||
61 | case self::STA_RECV: |
||
62 | break; |
||
63 | case self::STA_CLEAR: |
||
64 | $this->sized = Binary::int($this->buffer); |
||
65 | $this->state = self::STA_RECV; |
||
66 | break; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @var Promised $waiting |
||
71 | */ |
||
72 | |||
73 | if ($this->buffer->size() >= $this->sized) { |
||
74 | $waiting = $waiter(); |
||
75 | $this->state = self::STA_CLEAR; |
||
76 | $frame = new Frame($this->sized, $this->buffer); |
||
77 | switch (1) { |
||
78 | case $frame->isResponse(): |
||
79 | switch (1) { |
||
80 | case $frame->isOK(): |
||
81 | $waiting->resolve(true); |
||
82 | break; |
||
83 | case $frame->isHeartbeat(): |
||
84 | $nsqd->nop(); |
||
85 | break; |
||
86 | case $frame->isCloseWait(): |
||
87 | $waiting->resolve(); |
||
88 | $nsqd->close(); |
||
89 | break; |
||
90 | } |
||
91 | break; |
||
92 | case $frame->isMessage(): |
||
93 | $consuming->invoking($nsqd, $frame->getMessage()); |
||
|
|||
94 | break; |
||
95 | case $frame->isError(): |
||
96 | $waiting->pended() && $waiting->throw(new ServerException($frame->getError())); |
||
97 | break; |
||
98 | } |
||
99 | |||
100 | if ($this->buffer->valid()) { |
||
101 | goto PARSE_LOOP; |
||
102 | } |
||
106 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.