Conditions | 12 |
Paths | 13 |
Total Lines | 31 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
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 |
||
41 | protected function setAttribute($key, $value) |
||
42 | { |
||
43 | switch(mb_strtolower($key)) |
||
44 | { |
||
45 | case 'compression': |
||
46 | case 'compression lossless': |
||
47 | $this->lossless = ($value == 'true' || $value == 'Uncompressed'); |
||
48 | break; |
||
49 | |||
50 | case 'height': |
||
51 | case 'image height': |
||
52 | case 'tiff:imageheigth': |
||
53 | case 'tiff:imagelength': |
||
54 | $this->height = (int) $value; |
||
55 | break; |
||
56 | |||
57 | case 'width': |
||
58 | case 'image width': |
||
59 | case 'tiff:imagewidth': |
||
60 | $this->width = (int) $value; |
||
61 | break; |
||
62 | |||
63 | case 'x-tika:content': |
||
64 | $this->content = $value; |
||
65 | break; |
||
66 | |||
67 | default: |
||
68 | return false; |
||
69 | } |
||
70 | |||
71 | return true; |
||
72 | } |
||
74 |