Conditions | 10 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 110 |
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 |
||
99 | function onNext($value): void { |
||
100 | if($value instanceof \Plasma\Drivers\MySQL\Messages\PrepareStatementOkMessage) { |
||
101 | $this->okResponse = $value; |
||
102 | } elseif($value instanceof \Plasma\Drivers\MySQL\ProtocolOnNextCaller) { |
||
103 | $parsed = $this->handleQueryOnNextCallerColumns($value); |
||
104 | |||
105 | if($this->okResponse->numParams >= \count($this->params)) { |
||
106 | $this->params[] = $parsed; |
||
107 | } elseif($this->okResponse->numColumns >= \count($this->fields)) { |
||
108 | $this->fields[$parsed->getName()] = $parsed; |
||
109 | } else { |
||
110 | throw new \Plasma\Drivers\MySQL\Messages\ParseException('Command received more column definition packets than defined'); |
||
111 | } |
||
112 | } elseif( |
||
1 ignored issue
–
show
|
|||
113 | ($value instanceof \Plasma\Drivers\MySQL\Messages\EOFMessage || $value instanceof \Plasma\Drivers\MySQL\Messages\OkResponseMessage) |
||
1 ignored issue
–
show
|
|||
114 | && $this->okResponse->numParams <= \count($this->params) && $this->okResponse->numColumns <= \count($this->fields) |
||
115 | ) { |
||
116 | $this->finished = true; |
||
117 | |||
118 | $id = $this->okResponse->statementID; |
||
119 | $queryr = $this->rewrittenQuery; |
||
120 | $paramsr = $this->rewrittenParams; |
||
121 | |||
122 | $this->resolveValue = new \Plasma\Drivers\MySQL\Statement($this->client, $this->driver, $id, $this->query, $queryr, $paramsr, $this->params, $this->columns); |
||
123 | $this->deferred->resolve($this->resolveValue); |
||
124 | } else { |
||
125 | throw new \Plasma\Drivers\MySQL\Messages\ParseException('Command received value of type ' |
||
126 | .(\is_object($value) ? \get_class($value) : \gettype($value)).' it can not handle'); |
||
127 | } |
||
138 |