| Conditions | 11 |
| Paths | 20 |
| Total Lines | 52 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 42 | public function checkRequirements (bool $dontCheckPlugins = false) { |
||
| 43 | //get require |
||
| 44 | $require_array = $this->plugin->getRequiredPlugins(); |
||
| 45 | |||
| 46 | //get package list |
||
| 47 | require(STORE_PATH . "package_list.php"); |
||
| 48 | |||
| 49 | $missing_plugins = array(); |
||
| 50 | |||
| 51 | //iterate through all requirements |
||
| 52 | foreach ($require_array as $requirement=>$version) { |
||
| 53 | if ($requirement === "php") { |
||
| 54 | //TODO: check php version |
||
| 55 | } else if (PHPUtils::startsWith($requirement, "ext-")) { |
||
| 56 | //check php extension |
||
| 57 | } else if (PHPUtils::startsWith($requirement, "package-")) { |
||
| 58 | //TODO: check if package is installed |
||
| 59 | $package = str_replace("package-", "", $requirement); |
||
| 60 | |||
| 61 | //packages doesnt supports specific version |
||
| 62 | |||
| 63 | if (!isset($package_list[$package])) { |
||
|
|
|||
| 64 | $missing_plugins[] = $requirement; |
||
| 65 | } |
||
| 66 | } else if ($requirement === "core") { |
||
| 67 | //TODO: check core version |
||
| 68 | |||
| 69 | if ($version === "*") { |
||
| 70 | //we dont have to check version |
||
| 71 | } else { |
||
| 72 | //get current version |
||
| 73 | $array = explode(" ", Version::current()->getVersion()); |
||
| 74 | $current_core_version = $array[0]; |
||
| 75 | |||
| 76 | //check version |
||
| 77 | if (!$this->checkVersion($version, $current_core_version)) { |
||
| 78 | $missing_plugins[] = "core"; |
||
| 79 | } |
||
| 80 | } |
||
| 81 | } else { |
||
| 82 | if (!$dontCheckPlugins) { |
||
| 83 | continue; |
||
| 84 | } |
||
| 85 | |||
| 86 | //TODO: check installed plugins |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | if (empty($missing_plugins)) { |
||
| 91 | return true; |
||
| 92 | } else { |
||
| 93 | return $missing_plugins; |
||
| 94 | } |
||
| 137 |