| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| 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 |
||
| 10 | protected function blocoVI($y) |
||
| 11 | { |
||
| 12 | $this->bloco6H = 10; |
||
|
|
|||
| 13 | |||
| 14 | //$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
||
| 15 | //$this->pdf->textBox($this->margem, $y, $this->wPrint, $this->bloco6H, '', $aFont, 'T', 'C', false, '', false); |
||
| 16 | |||
| 17 | $texto = "Consulte pela Chave de Acesso em:"; |
||
| 18 | $aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
||
| 19 | $y1 = $this->pdf->textBox( |
||
| 20 | $this->margem, |
||
| 21 | $y, |
||
| 22 | $this->wPrint, |
||
| 23 | $this->bloco6H, |
||
| 24 | $texto, |
||
| 25 | $aFont, |
||
| 26 | 'T', |
||
| 27 | 'C', |
||
| 28 | false, |
||
| 29 | '', |
||
| 30 | false |
||
| 31 | ); |
||
| 32 | |||
| 33 | $texto = $this->urlChave; |
||
| 34 | $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
||
| 35 | $y2 = $this->pdf->textBox( |
||
| 36 | $this->margem, |
||
| 37 | $y+$y1, |
||
| 38 | $this->wPrint, |
||
| 39 | 2, |
||
| 40 | $texto, |
||
| 41 | $aFont, |
||
| 42 | 'T', |
||
| 43 | 'C', |
||
| 44 | false, |
||
| 45 | '', |
||
| 46 | false |
||
| 47 | ); |
||
| 48 | |||
| 49 | $chave = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); |
||
| 50 | $texto = $this->formatField($chave, $this->formatoChave); |
||
| 51 | $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
||
| 52 | $y3 = $this->pdf->textBox( |
||
| 53 | $this->margem, |
||
| 54 | $y+$y1+$y2+1, |
||
| 55 | $this->wPrint, |
||
| 56 | 2, |
||
| 57 | $texto, |
||
| 58 | $aFont, |
||
| 59 | 'T', |
||
| 60 | 'C', |
||
| 61 | false, |
||
| 62 | '', |
||
| 63 | true |
||
| 64 | ); |
||
| 65 | $this->pdf->dashedHLine($this->margem, $this->bloco6H+$y, $this->wPrint, 0.1, 30); |
||
| 66 | return $this->bloco6H + $y; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: