| Conditions | 9 | 
| Paths | 306 | 
| Total Lines | 57 | 
| Code Lines | 42 | 
| 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  | 
            ||
| 20 | public static function localList()  | 
            ||
| 21 |     { | 
            ||
| 22 | $ret=[];  | 
            ||
| 23 | $marketspaceRaw=self::getRemote();  | 
            ||
| 24 | $marketspace=[];  | 
            ||
| 25 |         foreach($marketspaceRaw["packages"] as $extension){ | 
            ||
| 26 | $marketspace[$extension["name"]]=$extension;  | 
            ||
| 27 | }  | 
            ||
| 28 | |||
| 29 | $localList=self::getLocal();  | 
            ||
| 30 | |||
| 31 |         foreach($localList as $extension){ | 
            ||
| 32 | $temp=[  | 
            ||
| 33 | "details"=>$extension,  | 
            ||
| 34 | "status"=>0,  | 
            ||
| 35 | "version"=>null,  | 
            ||
| 36 | "updatable"=>false,  | 
            ||
| 37 | "settings"=>null,  | 
            ||
| 38 | "available"=>null  | 
            ||
| 39 | ];  | 
            ||
| 40 | $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";  | 
            ||
| 41 |             try { | 
            ||
| 42 |                 if ($extension["version"]=='__cur__') { | 
            ||
| 43 |                     $extension["version"]=explode("-", version())[0]; | 
            ||
| 44 | }  | 
            ||
| 45 | $downloadedVersion=new Version($extension["version"]);  | 
            ||
| 46 | |||
| 47 |                 if(isset($marketspace[$extension["name"]])){ | 
            ||
| 48 | //remote extension, else is local extension  | 
            ||
| 49 | $remoteVersion=new Version($marketspace[$extension["name"]]["version"]);  | 
            ||
| 50 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);  | 
            ||
| 51 | $temp["details"]["official"]=$marketspace[$extension["name"]]["official"];  | 
            ||
| 52 |                 } else{ | 
            ||
| 53 | $temp["updatable"]=false;  | 
            ||
| 54 | $temp["details"]["official"]=0;  | 
            ||
| 55 | }  | 
            ||
| 56 | |||
| 57 | $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();  | 
            ||
| 58 |                 if (is_null($installedConfig)){ | 
            ||
| 59 | $temp["status"]=1;  | 
            ||
| 60 |                 } else { | 
            ||
| 61 | $temp["version"]=$installedConfig->version; // local installed version  | 
            ||
| 62 | $installedVersion=new Version($temp["version"]);  | 
            ||
| 63 |                     if ($downloadedVersion->isGreaterThan($installedVersion)){ | 
            ||
| 64 | $temp["status"]=1;  | 
            ||
| 65 |                     } else { | 
            ||
| 66 | $temp["status"]=2;  | 
            ||
| 67 | }  | 
            ||
| 68 | $temp["settings"]=false;  | 
            ||
| 69 | $temp["available"]=$installedConfig->status;  | 
            ||
| 70 | }  | 
            ||
| 71 |             }catch (Throwable $e){ | 
            ||
| 72 | continue;  | 
            ||
| 73 | }  | 
            ||
| 74 | $ret[]=$temp;  | 
            ||
| 75 | }  | 
            ||
| 76 | return $ret;  | 
            ||
| 77 | }  | 
            ||
| 164 |