| Conditions | 11 |
| Paths | 128 |
| Total Lines | 36 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 1 | 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 |
||
| 125 | protected function cells():string{ |
||
| 126 | $align = $this->getAttribute('align'); |
||
| 127 | $valign = $this->getAttribute('valign'); |
||
| 128 | $style = []; |
||
| 129 | $abbr = ''; |
||
| 130 | |||
| 131 | if($align && in_array($align, self::TEXT_ALIGN)){ |
||
| 132 | $style['text-align'] = $align; |
||
| 133 | } |
||
| 134 | |||
| 135 | if($valign && in_array($valign, ['baseline', 'bottom', 'middle', 'top'])){ |
||
| 136 | $style['vertical-align'] = $valign; |
||
| 137 | } |
||
| 138 | |||
| 139 | if($width = $this->getAttribute('width')){ |
||
| 140 | $style['width'] = $width; |
||
| 141 | } |
||
| 142 | |||
| 143 | if($this->getAttribute('nowrap')){ |
||
| 144 | $style['white-space'] = 'nowrap'; |
||
| 145 | } |
||
| 146 | |||
| 147 | if($colspan = $this->getAttribute('colspan')){ |
||
| 148 | $colspan = ' colspan="'.intval($colspan).'"'; |
||
| 149 | } |
||
| 150 | |||
| 151 | if($rowspan = $this->getAttribute('rowspan')){ |
||
| 152 | $rowspan = ' rowspan="'.intval($rowspan).'"'; |
||
| 153 | } |
||
| 154 | |||
| 155 | if($this->tag === 'th' && $abbr = $this->getAttribute('abbr')){ |
||
| 156 | $abbr = ' abbr="'.$abbr.'"'; |
||
| 157 | } |
||
| 158 | |||
| 159 | return '<'.$this->tag.$colspan.$rowspan.$abbr.$this->getStyle($style).'>'.$this->eol($this->content, $this->eol_token).'</'.$this->tag.'>'; |
||
| 160 | } |
||
| 161 | |||
| 163 |