Conditions | 12 |
Paths | 68 |
Total Lines | 43 |
Code Lines | 32 |
Lines | 0 |
Ratio | 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 |
||
62 | function siteInfoAdditionalManipulations($name) { |
||
63 | if (FALSE !== strpos($name, '_path')) { |
||
64 | $name = str_replace('_path', '', $name); |
||
65 | } |
||
66 | if (FALSE !== strpos($name, '_url')) { |
||
67 | $name = str_replace('_url', '', $name); |
||
68 | } |
||
69 | |||
70 | $siteinfo = new SiteInfo(); |
||
71 | $value = $siteinfo->getSiteInfo($name); |
||
72 | switch ($name) { |
||
73 | case 'siteinfo_favicon': |
||
74 | case 'siteinfo_logo': |
||
75 | // із врахуванням активного шаблону |
||
76 | if (is_array($value)) { |
||
77 | $settings = CI::$APP->cms_base->get_settings(); |
||
78 | if (array_key_exists($settings['site_template'], $value)) { |
||
79 | $fileName = $value[$settings['site_template']]; |
||
80 | if (SHOP_INSTALLED) { |
||
81 | $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme(); |
||
82 | |||
83 | return "/templates/{$settings['site_template']}/css/{$colorScheme}/{$fileName}"; |
||
84 | } else { |
||
85 | return "/templates/{$settings['site_template']}/images/{$fileName}"; |
||
86 | } |
||
87 | } elseif (count($value) > 0) { |
||
88 | reset($value); |
||
89 | $key = key($value); |
||
90 | if (SHOP_INSTALLED) { |
||
91 | $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme(); |
||
92 | $template = TemplateManager::getInstance()->getCurentTemplate(); |
||
93 | return '/templates/' . $template->name . "/css/{$colorScheme}/" . $value[$key]; |
||
94 | } else { |
||
95 | return "/templates/{$settings['site_template']}/images/" . array_shift($value); |
||
96 | } |
||
97 | } |
||
98 | return ''; |
||
99 | } elseif (is_string($value)) { |
||
100 | return empty($value) ? '' : CI::$APP->siteinfo->imagesPath . $value; |
||
101 | } |
||
102 | } |
||
103 | return false; |
||
104 | } |
||
105 | |||
106 | } |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.