| Conditions | 16 |
| Paths | 136 |
| Total Lines | 38 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 104 | public function __toString() |
||
| 105 | { |
||
| 106 | $transforms = ''; |
||
| 107 | |||
| 108 | if (array_key_exists('fit-in', $this->transformations)) { |
||
| 109 | $transforms .= '/fit-in'; |
||
| 110 | } |
||
| 111 | |||
| 112 | if (array_key_exists('width', $this->transformations)) { |
||
| 113 | $transforms .= '/' . $this->transformations['width'] . 'x' . $this->transformations['height']; |
||
| 114 | } |
||
| 115 | |||
| 116 | if (array_key_exists('focus', $this->transformations) && $this->transformations['focus'] === 'smart') { |
||
| 117 | $transforms .= '/smart'; |
||
| 118 | } |
||
| 119 | |||
| 120 | // filters |
||
| 121 | if (array_key_exists('format', $this->transformations) || array_key_exists('quality', $this->transformations) || array_key_exists('fill', $this->transformations) || (array_key_exists('focus', $this->transformations) && $this->transformations['focus'] === 'focal-point')) { |
||
| 122 | $transforms .= '/filters'; |
||
| 123 | |||
| 124 | if (array_key_exists('format', $this->transformations)) { |
||
| 125 | $transforms .= ':format(' . $this->transformations['format'] . ')'; |
||
| 126 | } |
||
| 127 | |||
| 128 | if (array_key_exists('quality', $this->transformations)) { |
||
| 129 | $transforms .= ':quality(' . $this->transformations['quality'] . ')'; |
||
| 130 | } |
||
| 131 | |||
| 132 | if (array_key_exists('fill', $this->transformations)) { |
||
| 133 | $transforms .= ':fill(' . $this->transformations['fill'] . ')'; |
||
| 134 | } |
||
| 135 | |||
| 136 | if (array_key_exists('focus', $this->transformations) && $this->transformations['focus'] === 'focal-point' && $this->focus) { |
||
| 137 | $transforms .= ':focal(' . $this->focus . ')'; |
||
| 138 | } |
||
| 139 | } |
||
| 140 | |||
| 141 | return $this->createUrl($transforms); |
||
| 142 | } |
||
| 143 | } |