| Conditions | 9 |
| Paths | 24 |
| Total Lines | 51 |
| Code Lines | 30 |
| 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 |
||
| 20 | public function up(Schema $schema): void |
||
| 21 | { |
||
| 22 | global $_configuration; |
||
| 23 | |||
| 24 | $rootPath = $this->getRootPath(); |
||
| 25 | $oldConfigPath = $rootPath . '/app/config/configuration.php'; |
||
| 26 | if (!\in_array($oldConfigPath, get_included_files(), true)) { |
||
| 27 | include_once $oldConfigPath; |
||
| 28 | } |
||
| 29 | |||
| 30 | // Update .env and .env.local files |
||
| 31 | $this->updateEnvFiles($rootPath, [ |
||
| 32 | "DB_MANAGER_ENABLED" => $_configuration['db_manager_enabled'] ? '1' : '0', |
||
| 33 | "SOFTWARE_NAME" => $_configuration['software_name'], |
||
| 34 | "SOFTWARE_URL" => $_configuration['software_url'], |
||
| 35 | "DENY_DELETE_USERS" => $_configuration['deny_delete_users'] ? '1' : '0', |
||
| 36 | "HOSTING_TOTAL_SIZE_LIMIT" => $_configuration['hosting_total_size_limit'] |
||
| 37 | ]); |
||
| 38 | |||
| 39 | // Ensure the hosting_limits.yml file exists |
||
| 40 | $hostingLimitsFile = $rootPath . '/config/hosting_limits.yml'; |
||
| 41 | $hostingLimits = ['hosting_limits' => ['urls' => []]]; |
||
| 42 | |||
| 43 | // Prepare hosting limits |
||
| 44 | foreach ($_configuration as $urlId => $config) { |
||
| 45 | if (is_array($config)) { |
||
| 46 | $hostingLimits['hosting_limits']['urls'][$urlId] = [ |
||
| 47 | ['hosting_limit_users' => $config['hosting_limit_users'] ?? 0], |
||
| 48 | ['hosting_limit_teachers' => $config['hosting_limit_teachers'] ?? 0], |
||
| 49 | ['hosting_limit_courses' => $config['hosting_limit_courses'] ?? 0], |
||
| 50 | ['hosting_limit_sessions' => $config['hosting_limit_sessions'] ?? 0], |
||
| 51 | ['hosting_limit_disk_space' => $config['hosting_limit_disk_space'] ?? 0], |
||
| 52 | ['hosting_limit_active_courses' => $config['hosting_limit_active_courses'] ?? 0], |
||
| 53 | ['hosting_total_size_limit' => $_configuration['hosting_total_size_limit'] ?? 0] |
||
| 54 | ]; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | // Format hosting limits as YAML |
||
| 59 | $yamlContent = "hosting_limits:\n urls:\n"; |
||
| 60 | foreach ($hostingLimits['hosting_limits']['urls'] as $urlId => $limits) { |
||
| 61 | $yamlContent .= " {$urlId}:\n"; |
||
| 62 | foreach ($limits as $limit) { |
||
| 63 | foreach ($limit as $key => $value) { |
||
| 64 | $yamlContent .= " - {$key}: {$value}\n"; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | // Write hosting limits to hosting_limits.yml |
||
| 70 | file_put_contents($hostingLimitsFile, $yamlContent); |
||
| 71 | } |
||
| 125 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.