| Conditions | 7 |
| Paths | 6 |
| Total Lines | 55 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 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 |
||
| 41 | function decode($data) {
|
||
| 42 | |||
| 43 | if($data[0] == 0x00 && $data[1] == 0x01) {
|
||
| 44 | $this->fpdi->error("LZW flavour not supported.");
|
||
| 45 | } |
||
| 46 | |||
| 47 | $this->initsTable(); |
||
| 48 | |||
| 49 | $this->data = $data; |
||
| 50 | |||
| 51 | // Initialize pointers |
||
| 52 | $this->bytePointer = 0; |
||
| 53 | $this->bitPointer = 0; |
||
| 54 | |||
| 55 | $this->nextData = 0; |
||
| 56 | $this->nextBits = 0; |
||
| 57 | |||
| 58 | $oldCode = 0; |
||
| 59 | |||
| 60 | $string = ""; |
||
| 61 | $uncompData = ""; |
||
| 62 | |||
| 63 | while (($code = $this->getNextCode()) != 257) {
|
||
| 64 | if ($code == 256) {
|
||
| 65 | $this->initsTable(); |
||
| 66 | $code = $this->getNextCode(); |
||
| 67 | |||
| 68 | if ($code == 257) {
|
||
| 69 | break; |
||
| 70 | } |
||
| 71 | |||
| 72 | $uncompData .= $this->sTable[$code]; |
||
| 73 | $oldCode = $code; |
||
| 74 | |||
| 75 | } else {
|
||
| 76 | |||
| 77 | if ($code < $this->tIdx) {
|
||
| 78 | $string = $this->sTable[$code]; |
||
| 79 | $uncompData .= $string; |
||
| 80 | |||
| 81 | $this->addStringToTable($this->sTable[$oldCode], $string[0]); |
||
| 82 | $oldCode = $code; |
||
| 83 | } else {
|
||
| 84 | $string = $this->sTable[$oldCode]; |
||
| 85 | $string = $string.$string[0]; |
||
| 86 | $uncompData .= $string; |
||
| 87 | |||
| 88 | $this->addStringToTable($string); |
||
| 89 | $oldCode = $code; |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | return $uncompData; |
||
| 95 | } |
||
| 96 | |||
| 147 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.