| Conditions | 15 |
| Paths | 17 |
| Total Lines | 47 |
| 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 |
||
| 33 | public function getDataExtension( |
||
| 34 | $getDataString, |
||
| 35 | array $fields, |
||
| 36 | $sectionValue, |
||
| 37 | $returnValue, |
||
| 38 | ContentObjectRenderer &$parentObject |
||
| 39 | ) { |
||
| 40 | $parts = \explode(':', $getDataString); |
||
| 41 | if (isset($parts[0], $parts[1]) && 'fp' === $parts[0]) { |
||
| 42 | $fileObject = $parentObject->getCurrentFile(); |
||
| 43 | if (!($fileObject instanceof FileReference)) { |
||
| 44 | return $returnValue; |
||
| 45 | } |
||
| 46 | $originalFile = $fileObject->getOriginalFile(); |
||
| 47 | switch ($parts[1]) { |
||
| 48 | case 'x': |
||
| 49 | case 'y': |
||
| 50 | $metaData = $originalFile->_getMetaData(); |
||
| 51 | |||
| 52 | return $metaData['focus_point_' . $parts[1]] / 100; |
||
| 53 | case 'xp': |
||
| 54 | case 'yp': |
||
| 55 | $metaData = $originalFile->_getMetaData(); |
||
| 56 | |||
| 57 | return (float) $metaData['focus_point_' . \mb_substr($parts[1], 0, 1)]; |
||
| 58 | case 'xp_positive': |
||
| 59 | case 'yp_positive': |
||
| 60 | $metaData = $originalFile->_getMetaData(); |
||
| 61 | if ('xp_positive' === $parts[1]) { |
||
| 62 | return (int) (\abs($metaData['focus_point_' . \mb_substr($parts[1], 0, 1)] + 100) / 2); |
||
| 63 | } |
||
| 64 | |||
| 65 | return (int) (\abs($metaData['focus_point_' . \mb_substr($parts[1], 0, 1)] - 100) / 2); |
||
| 66 | case 'w': |
||
| 67 | case 'h': |
||
| 68 | $fileName = GeneralUtility::getFileAbsFileName($fileObject->getPublicUrl(true)); |
||
| 69 | if (\file_exists($fileName)) { |
||
| 70 | $sizes = \getimagesize($fileName); |
||
| 71 | |||
| 72 | return $sizes[('w' === $parts[1] ? 0 : 1)]; |
||
| 73 | } |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | return $returnValue; |
||
| 79 | } |
||
| 80 | } |
||
| 81 |