| Conditions | 10 |
| Paths | 12 |
| Total Lines | 43 |
| Code Lines | 29 |
| 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 |
||
| 16 | function procSyndicationAdminInsertConfig() |
||
| 17 | { |
||
| 18 | $oModuleController = getController('module'); |
||
| 19 | $oSyndicationController = getController('syndication'); |
||
|
|
|||
| 20 | $oSyndicationModel = getModel('syndication'); |
||
| 21 | |||
| 22 | $config = new stdClass; |
||
| 23 | $config->syndication_use = Context::get('syndication_use'); |
||
| 24 | $config->site_url = preg_replace('/\/+$/is','',Context::get('site_url')); |
||
| 25 | $config->year = Context::get('year'); |
||
| 26 | $config->syndication_token = Context::get('syndication_token'); |
||
| 27 | $config->syndication_password = urlencode(Context::get('syndication_password')); |
||
| 28 | |||
| 29 | if(!$config->site_url) return $this->makeObject(-1,'msg_site_url_is_null'); |
||
| 30 | if(!$config->syndication_token) return $this->makeObject(-1,'msg_syndication_token_is_null'); |
||
| 31 | |||
| 32 | $oModuleController->updateModuleConfig('syndication',$config); |
||
| 33 | |||
| 34 | $except_module = Context::get('except_module'); |
||
| 35 | $output = executeQuery('syndication.deleteExceptModules'); |
||
| 36 | if(!$output->toBool()) return $output; |
||
| 37 | |||
| 38 | if ($except_module){ |
||
| 39 | $modules = explode(',',$except_module); |
||
| 40 | for($i=0,$c=count($modules);$i<$c;$i++) { |
||
| 41 | $args->module_srl = $modules[$i]; |
||
| 42 | $output = executeQuery('syndication.insertExceptModule',$args); |
||
| 43 | if(!$output->toBool()) return $output; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | if(!$this->checkOpenSSLSupport()) |
||
| 48 | { |
||
| 49 | return $this->makeObject(-1, 'msg_need_openssl_support'); |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->setMessage('success_applied'); |
||
| 53 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { |
||
| 54 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSyndicationAdminConfig'); |
||
| 55 | $this->setRedirectUrl($returnUrl); |
||
| 56 | return; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 87 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.