| Conditions | 19 |
| Paths | 2880 |
| Total Lines | 79 |
| 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 namespace EvolutionCMS; |
||
| 28 | public function init($modx = null) |
||
| 29 | { |
||
| 30 | if ($modx === null) { |
||
| 31 | $modx = evolutionCMS(); |
||
| 32 | } |
||
| 33 | $this->modx = $modx; |
||
| 34 | $this->PluginDir = MODX_MANAGER_PATH . 'includes/controls/phpmailer/'; |
||
| 35 | |||
| 36 | switch ($modx->getConfig('email_method')) { |
||
| 37 | case 'smtp': |
||
| 38 | $this->isSMTP(); |
||
| 39 | $this->SMTPSecure = $modx->getConfig('smtp_secure') === 'none' ? '' : $modx->getConfig('smtp_secure'); |
||
| 40 | $this->Port = $modx->getConfig('smtp_port'); |
||
| 41 | $this->Host = $modx->getConfig('smtp_host'); |
||
| 42 | $this->SMTPAuth = $modx->getConfig('smtp_auth') === '1' ? true : false; |
||
| 43 | $this->Username = $modx->getConfig('smtp_username'); |
||
| 44 | $this->Password = $modx->getConfig('smtppw'); |
||
| 45 | if (10 < strlen($this->Password)) { |
||
| 46 | $this->Password = substr($this->Password, 0, -7); |
||
| 47 | $this->Password = str_replace('%', '=', $this->Password); |
||
| 48 | $this->Password = base64_decode($this->Password); |
||
| 49 | } |
||
| 50 | break; |
||
| 51 | case 'mail': |
||
| 52 | default: |
||
| 53 | $this->isMail(); |
||
| 54 | } |
||
| 55 | |||
| 56 | $this->From = $modx->getConfig('emailsender'); |
||
| 57 | if (isset($modx->config['email_sender_method']) && !$modx->config['email_sender_method']) { |
||
| 58 | $this->Sender = $modx->getConfig('emailsender'); |
||
| 59 | } |
||
| 60 | $this->FromName = $modx->getPhpCompat()->entities($modx->getConfig('site_name')); |
||
| 61 | $this->isHTML(true); |
||
| 62 | |||
| 63 | if (isset($modx->config['mail_charset']) && !empty($modx->config['mail_charset'])) { |
||
| 64 | $mail_charset = $modx->getConfig('mail_charset'); |
||
| 65 | } else { |
||
| 66 | if (substr($modx->getConfig('manager_language'), 0, 8) === 'japanese') { |
||
| 67 | $mail_charset = 'jis'; |
||
| 68 | } else { |
||
| 69 | $mail_charset = $modx->getConfig('modx_charset'); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | switch ($mail_charset) { |
||
| 74 | case 'iso-8859-1': |
||
| 75 | $this->CharSet = 'iso-8859-1'; |
||
| 76 | $this->Encoding = 'quoted-printable'; |
||
| 77 | $this->mb_language = 'English'; |
||
| 78 | break; |
||
| 79 | case 'jis': |
||
| 80 | $this->CharSet = 'ISO-2022-JP'; |
||
| 81 | $this->Encoding = '7bit'; |
||
| 82 | $this->mb_language = 'Japanese'; |
||
| 83 | $this->encode_header_method = 'mb_encode_mimeheader'; |
||
| 84 | $this->isHTML(false); |
||
| 85 | break; |
||
| 86 | case 'windows-1251': |
||
| 87 | $this->CharSet = 'cp1251'; |
||
| 88 | break; |
||
| 89 | case 'utf8': |
||
| 90 | case 'utf-8': |
||
| 91 | default: |
||
| 92 | $this->CharSet = 'UTF-8'; |
||
| 93 | $this->Encoding = 'base64'; |
||
| 94 | $this->mb_language = 'UNI'; |
||
| 95 | } |
||
| 96 | if (extension_loaded('mbstring')) { |
||
| 97 | mb_language($this->mb_language); |
||
| 98 | mb_internal_encoding($modx->getConfig('modx_charset')); |
||
| 99 | } |
||
| 100 | $exconf = MODX_MANAGER_PATH . 'includes/controls/phpmailer/config.inc.php'; |
||
| 101 | if (is_file($exconf)) { |
||
| 102 | include($exconf); |
||
| 103 | } |
||
| 104 | |||
| 105 | return $this; |
||
| 106 | } |
||
| 107 | |||
| 345 |
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.