Conditions | 11 |
Paths | 48 |
Total Lines | 42 |
Code Lines | 27 |
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 |
||
11 | public static function fileLabel($id, $nolink = false, $icon = true, $action_urls = null, $label = null, $inline = false) |
||
12 | { |
||
13 | $fileExists = File::exists($id); |
||
14 | |||
15 | if ($icon) { |
||
16 | $icon_file = $fileExists ? 'z-attach.png': 'z-attach-off.png'; |
||
17 | $img_src = Base_ThemeCommon::get_template_file(self::module_name(), $icon_file); |
||
18 | $icon_img = '<img src="' . $img_src . '" style="vertical-align:bottom">'; |
||
19 | } |
||
20 | else { |
||
21 | $icon_img = ''; |
||
22 | } |
||
23 | |||
24 | $file = File::get($id); |
||
25 | |||
26 | if (! $fileName = $label) { |
||
27 | $fileName = ($file['name']?? '') ?: '[' . __('missing file name') . ']'; |
||
28 | } |
||
29 | |||
30 | if ($nolink || ! $file) { |
||
31 | return $fileName . ($fileExists ? '': ' [' . __('missing file') . ']'); |
||
32 | } |
||
33 | |||
34 | $link_href = ''; |
||
35 | if ($fileExists) { |
||
36 | $filesize = filesize_hr($file['file']); |
||
37 | $filetooltip = __('File size: %s', array($filesize)) . '<hr>' . |
||
38 | __('Uploaded by: %s', array(Base_UserCommon::get_user_label($file['created_by'], true))) . '<br/>' . |
||
39 | __('Uploaded on: %s', array(Base_RegionalSettingsCommon::time2reg($file['created_on']))) . '<br/>' . |
||
40 | __('Number of downloads: %d', array(self::get_downloads_count($id))); |
||
41 | $link_href = Utils_TooltipCommon::open_tag_attrs($filetooltip) . ' ' |
||
42 | . Utils_FileStorage_FileLeightbox::get_file_leightbox($file, $action_urls); |
||
43 | } else { |
||
44 | if (isset($file['hash'])) { |
||
45 | $tooltip_text = __('Missing file: %s', array(substr($file['hash'], 0, 32) . '...')); |
||
46 | $link_href = Utils_TooltipCommon::open_tag_attrs($tooltip_text); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | $ret = '<a ' . $link_href . '>' . $icon_img . '<span class="file_name">' . $fileName . '</span></a>'; |
||
51 | |||
52 | return $inline? $ret: '<div class="file_link">'.$ret.'</div>'; |
||
53 | } |
||
55 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.