| Conditions | 13 |
| Paths | 4 |
| Total Lines | 63 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| 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 |
||
| 93 | private function decodeBitStream(BitBuffer $bitBuffer):DecoderResult{ |
||
| 94 | $this->bitBuffer = $bitBuffer; |
||
| 95 | $this->eciCharset = null; |
||
| 96 | $versionNumber = $this->version->getVersionNumber(); |
||
|
|
|||
| 97 | $symbolSequence = -1; |
||
| 98 | $parityData = -1; |
||
| 99 | $fc1InEffect = false; |
||
| 100 | $result = ''; |
||
| 101 | |||
| 102 | // While still another segment to read... |
||
| 103 | while($this->bitBuffer->available() >= 4){ |
||
| 104 | $datamode = $this->bitBuffer->read(4); // mode is encoded by 4 bits |
||
| 105 | |||
| 106 | // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here |
||
| 107 | if($datamode === Mode::TERMINATOR){ |
||
| 108 | break; |
||
| 109 | } |
||
| 110 | elseif($datamode === Mode::ECI){ |
||
| 111 | $this->eciCharset = ECI::parseValue($this->bitBuffer); |
||
| 112 | } |
||
| 113 | elseif($datamode === Mode::FNC1_FIRST || $datamode === Mode::FNC1_SECOND){ |
||
| 114 | // We do little with FNC1 except alter the parsed result a bit according to the spec |
||
| 115 | $fc1InEffect = true; |
||
| 116 | } |
||
| 117 | elseif($datamode === Mode::STRCTURED_APPEND){ |
||
| 118 | |||
| 119 | if($this->bitBuffer->available() < 16){ |
||
| 120 | throw new QRCodeDecoderException('structured append: not enough bits left'); |
||
| 121 | } |
||
| 122 | // sequence number and parity is added later to the result metadata |
||
| 123 | // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue |
||
| 124 | $symbolSequence = $this->bitBuffer->read(8); |
||
| 125 | $parityData = $this->bitBuffer->read(8); |
||
| 126 | } |
||
| 127 | elseif($datamode === Mode::NUMBER){ |
||
| 128 | $result .= Number::decodeSegment($this->bitBuffer, $versionNumber); |
||
| 129 | } |
||
| 130 | elseif($datamode === Mode::ALPHANUM){ |
||
| 131 | $result .= $this->decodeAlphanumSegment($versionNumber, $fc1InEffect); |
||
| 132 | } |
||
| 133 | elseif($datamode === Mode::BYTE){ |
||
| 134 | $result .= $this->decodeByteSegment($versionNumber); |
||
| 135 | } |
||
| 136 | elseif($datamode === Mode::KANJI){ |
||
| 137 | $result .= Kanji::decodeSegment($this->bitBuffer, $versionNumber); |
||
| 138 | } |
||
| 139 | elseif($datamode === Mode::HANZI){ |
||
| 140 | $result .= Hanzi::decodeSegment($this->bitBuffer, $versionNumber); |
||
| 141 | } |
||
| 142 | else{ |
||
| 143 | throw new QRCodeDecoderException('invalid data mode'); |
||
| 144 | } |
||
| 145 | |||
| 146 | } |
||
| 147 | |||
| 148 | return new DecoderResult([ |
||
| 149 | 'rawBytes' => $this->bitBuffer, |
||
| 150 | 'data' => $result, |
||
| 151 | 'version' => $this->version, |
||
| 152 | 'eccLevel' => $this->eccLevel, |
||
| 153 | 'maskPattern' => $this->maskPattern, |
||
| 154 | 'structuredAppendParity' => $parityData, |
||
| 155 | 'structuredAppendSequence' => $symbolSequence, |
||
| 156 | ]); |
||
| 206 |
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.