| Conditions | 10 | 
| Paths | 11 | 
| Total Lines | 47 | 
| Code Lines | 34 | 
| 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  | 
            ||
| 96 | public static function checkVerModule($helper, $source = 'github', $default = 'master')  | 
            ||
| 97 |     { | 
            ||
| 98 | $moduleDirName = basename(dirname(dirname(__DIR__)));  | 
            ||
| 99 | $moduleDirNameUpper = mb_strtoupper($moduleDirName);  | 
            ||
| 100 | $update = '';  | 
            ||
| 101 | $repository = 'XoopsModules25x/' . $moduleDirName;  | 
            ||
| 102 | // $repository = 'XoopsModules25x/publisher'; //for testing only  | 
            ||
| 103 | $ret = '';  | 
            ||
| 104 | $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";  | 
            ||
| 105 |         if ('github' === $source) { | 
            ||
| 106 |             if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) { | 
            ||
| 107 | curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl);  | 
            ||
| 108 | curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);  | 
            ||
| 109 | curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);  | 
            ||
| 110 | curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);  | 
            ||
| 111 | $curlReturn = curl_exec($curlHandle);  | 
            ||
| 112 |                 if (false === $curlReturn) { | 
            ||
| 113 | trigger_error(curl_error($curlHandle));  | 
            ||
| 114 |                 } else { | 
            ||
| 115 | $file = json_decode($curlReturn, false);  | 
            ||
| 116 |                     $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); | 
            ||
| 117 | $latestVersion = $file[0]->tag_name;  | 
            ||
| 118 | $prerelease = $file[0]->prerelease;  | 
            ||
| 119 |                     if ('master' !== $latestVersionLink) { | 
            ||
| 120 |                         $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; | 
            ||
| 121 | }  | 
            ||
| 122 | //"PHP-standardized" version  | 
            ||
| 123 | $latestVersion = mb_strtolower($latestVersion);  | 
            ||
| 124 |                     if (false !== mb_strpos($latestVersion, 'final')) { | 
            ||
| 125 |                         $latestVersion = str_replace('_', '', mb_strtolower($latestVersion)); | 
            ||
| 126 |                         $latestVersion = str_replace('final', '', mb_strtolower($latestVersion)); | 
            ||
| 127 | }  | 
            ||
| 128 |                     $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); | 
            ||
| 129 | //"PHP-standardized" version  | 
            ||
| 130 |                     $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion)); | 
            ||
| 131 | // $moduleVersion = '1.0'; //for testing only  | 
            ||
| 132 | // $moduleDirName = 'publisher'; //for testing only  | 
            ||
| 133 |                     if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) { | 
            ||
| 134 | $ret = [];  | 
            ||
| 135 | $ret[] = $update;  | 
            ||
| 136 | $ret[] = $latestVersionLink;  | 
            ||
| 137 | }  | 
            ||
| 138 | }  | 
            ||
| 139 | curl_close($curlHandle);  | 
            ||
| 140 | }  | 
            ||
| 141 | }  | 
            ||
| 142 | return $ret;  | 
            ||
| 143 | }  | 
            ||
| 145 |