Conditions | 5 |
Paths | 16 |
Total Lines | 53 |
Lines | 27 |
Ratio | 50.94 % |
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 |
||
30 | public function render() |
||
31 | { |
||
32 | $file = $this->getFileConverter()->convert($this->object); |
||
33 | |||
34 | $result = ''; |
||
35 | |||
36 | // Add number of references on the top! |
||
37 | if ($this->object['number_of_references'] > 1) { |
||
38 | $result .= sprintf( |
||
39 | '<div><strong>%s (%s)</strong></div>', |
||
40 | $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:references'), |
||
41 | $this->object['number_of_references'] |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | // Render File usage |
||
46 | $fileReferences = $this->getFileReferenceService()->findFileReferences($file); |
||
47 | View Code Duplication | if (!empty($fileReferences)) { |
|
|
|||
48 | |||
49 | // Finalize file references assembling. |
||
50 | $result .= sprintf( |
||
51 | $this->getWrappingTemplate(), |
||
52 | $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:file_reference'), |
||
53 | $this->assembleOutput($fileReferences, array('referenceIdentifier' => 'uid_foreign', 'tableName' => 'tablenames')) |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | // Render link usage in RTE |
||
58 | $linkSoftReferences = $this->getFileReferenceService()->findSoftLinkReferences($file); |
||
59 | View Code Duplication | if (!empty($linkSoftReferences)) { |
|
60 | |||
61 | // Finalize link references assembling. |
||
62 | $result .= sprintf( |
||
63 | $this->getWrappingTemplate(), |
||
64 | $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:link_references_in_rte'), |
||
65 | $this->assembleOutput($linkSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename')) |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | // Render image usage in RTE |
||
70 | $imageSoftReferences = $this->getFileReferenceService()->findSoftImageReferences($file); |
||
71 | View Code Duplication | if (!empty($imageSoftReferences)) { |
|
72 | |||
73 | // Finalize image references assembling. |
||
74 | $result .= sprintf( |
||
75 | $this->getWrappingTemplate(), |
||
76 | $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:image_references_in_rte'), |
||
77 | $this->assembleOutput($imageSoftReferences, array('referenceIdentifier' => 'recuid', 'tableName' => 'tablename')) |
||
78 | ); |
||
79 | } |
||
80 | |||
81 | return $result; |
||
82 | } |
||
83 | |||
235 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.