| Conditions | 15 |
| Paths | 8192 |
| Total Lines | 58 |
| 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 |
||
| 69 | public function _make_share_form($url = '') { |
||
| 70 | |||
| 71 | $url = $url ?: site_url(CoreFactory::getUrlParser()->getFullUrl(false)); |
||
| 72 | |||
| 73 | $settings = $this->settings; |
||
| 74 | $services = ''; |
||
| 75 | if ($settings['yaru'] == 1) { |
||
| 76 | $services .= 'yaru,'; |
||
| 77 | } |
||
| 78 | if ($settings['vkcom'] == 1) { |
||
| 79 | $services .= 'vkontakte,'; |
||
| 80 | } |
||
| 81 | if ($settings['facebook'] == 1) { |
||
| 82 | $services .= 'facebook,'; |
||
| 83 | } |
||
| 84 | if ($settings['twitter'] == 1) { |
||
| 85 | $services .= 'twitter,'; |
||
| 86 | } |
||
| 87 | if ($settings['odnoclass'] == 1) { |
||
| 88 | $services .= 'odnoklassniki,'; |
||
| 89 | } |
||
| 90 | if ($settings['myworld'] == 1) { |
||
| 91 | $services .= 'moimir,'; |
||
| 92 | } |
||
| 93 | if ($settings['lj'] == 1) { |
||
| 94 | $services .= 'lj,'; |
||
| 95 | } |
||
| 96 | if ($settings['ff'] == 1) { |
||
| 97 | $services .= 'friendfeed,'; |
||
| 98 | } |
||
| 99 | if ($settings['mc'] == 1) { |
||
| 100 | $services .= 'moikrug,'; |
||
| 101 | } |
||
| 102 | if ($settings['gg'] == 1) { |
||
| 103 | $services .= 'gplus,'; |
||
| 104 | } |
||
| 105 | |||
| 106 | if ($settings['type'] == 'counter') { |
||
| 107 | $type = ' data-counter=""'; |
||
| 108 | } elseif ($settings['type'] == 'button') { |
||
| 109 | $type = ''; |
||
| 110 | } elseif ($settings['type'] == 'icon') { |
||
| 111 | $type = ' data-limit="3"'; |
||
| 112 | } |
||
| 113 | |||
| 114 | \CI_Controller::get_instance() |
||
| 115 | ->template |
||
| 116 | ->registerJsScript('<script async="async" type="text/javascript" src="//yastatic.net/es5-shims/0.0.2/es5-shims.min.js" charset="utf-8"></script>', 'before'); |
||
| 117 | \CI_Controller::get_instance() |
||
| 118 | ->template |
||
| 119 | ->registerJsScript('<script type="text/javascript" src="//yastatic.net/share2/share.js" charset="utf-8"></script>', 'before'); |
||
| 120 | |||
| 121 | $html = '<div class="ya-share2" data-lang="ru" data-url="' . $url . '"' |
||
| 122 | . $type |
||
| 123 | . ' data-services="' . $services . '"></div>'; |
||
| 124 | |||
| 125 | return $html; |
||
| 126 | } |
||
| 127 | |||
| 221 | } |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.