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