| Conditions | 11 |
| Paths | 11 |
| Total Lines | 30 |
| 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 |
||
| 24 | public function __construct($source=null, $args=null) |
||
| 25 | { |
||
| 26 | parent::__construct(array(), false); |
||
| 27 | $this->ID = -1; |
||
| 28 | $this->Filename = CloudAssets::config()->missing_image; |
||
| 29 | $this->source = $source; |
||
| 30 | if (empty($args)) { |
||
| 31 | $this->dimensions = '100x100'; |
||
| 32 | } else { |
||
| 33 | switch ($args[0]) { |
||
| 34 | case 'SetWidth'; |
||
| 35 | case 'SetHeight': |
||
| 36 | case 'ScaleWidth': |
||
| 37 | case 'ScaleHeight': |
||
| 38 | $this->dimensions = $args[1] . 'x' . $args[1]; |
||
| 39 | break; |
||
| 40 | |||
| 41 | case 'SetSize'; |
||
| 42 | case 'SetRatioSize'; |
||
| 43 | case 'ResizedImage'; |
||
| 44 | case 'CroppedImage'; |
||
| 45 | case 'PaddedImage': |
||
| 46 | $this->dimensions = $args[1] . 'x' . $args[2]; |
||
| 47 | break; |
||
| 48 | |||
| 49 | default: |
||
| 50 | $this->dimensions = '100x100'; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 108 |