Conditions | 13 |
Paths | 16 |
Total Lines | 60 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
22 | public function up(Schema $schema): void |
||
23 | { |
||
24 | global $_configuration; |
||
25 | |||
26 | $rootPath = $this->getRootPath(); |
||
27 | $updateRootPath = $this->getUpdateRootPath(); |
||
28 | $oldConfigPath = $updateRootPath.'/app/config/configuration.php'; |
||
29 | if (!\in_array($oldConfigPath, get_included_files(), true)) { |
||
30 | include_once $oldConfigPath; |
||
31 | } |
||
32 | |||
33 | // Update .env and .env.local files |
||
34 | $this->updateEnvFiles($rootPath, [ |
||
35 | 'DB_MANAGER_ENABLED' => !empty($_configuration['db_manager_enabled']) ? '1' : '0', |
||
36 | 'SOFTWARE_NAME' => $_configuration['software_name'] ?? '', |
||
37 | 'SOFTWARE_URL' => $_configuration['software_url'] ?? '', |
||
38 | 'DENY_DELETE_USERS' => !empty($_configuration['deny_delete_users']) ? '1' : '0', |
||
39 | 'HOSTING_TOTAL_SIZE_LIMIT' => $_configuration['hosting_total_size_limit'] ?? 0, |
||
40 | 'THEME_FALLBACK' => $_configuration['theme_fallback'] ?? 'chamilo', |
||
41 | 'PACKAGER' => $_configuration['packager'] ?? 'chamilo', |
||
42 | 'DEFAULT_TEMPLATE' => $_configuration['default_template'] ?? 'default', |
||
43 | 'ADMIN_CHAMILO_ANNOUNCEMENTS_DISABLE' => !empty($_configuration['admin_chamilo_announcements_disable']) ? '1' : '0', |
||
44 | 'WEBSERVICE_ENABLE' => !empty($_configuration['webservice_enable']) ? '1' : '0', |
||
45 | ]); |
||
46 | |||
47 | // Ensure the hosting_limits.yml file exists |
||
48 | $hostingLimitsFile = $rootPath.'/config/hosting_limits.yml'; |
||
49 | $hostingLimits = ['hosting_limits' => ['urls' => []]]; |
||
50 | |||
51 | // Prepare hosting limits |
||
52 | if (\is_array($_configuration)) { |
||
53 | foreach ($_configuration as $key => $config) { |
||
54 | if (is_numeric($key) && \is_array($config)) { |
||
55 | // Handle configurations specific to URL IDs |
||
56 | $hostingLimits['hosting_limits']['urls'][$key] = [ |
||
57 | ['hosting_limit_users' => $config['hosting_limit_users'] ?? 0], |
||
58 | ['hosting_limit_teachers' => $config['hosting_limit_teachers'] ?? 0], |
||
59 | ['hosting_limit_courses' => $config['hosting_limit_courses'] ?? 0], |
||
60 | ['hosting_limit_sessions' => $config['hosting_limit_sessions'] ?? 0], |
||
61 | ['hosting_limit_disk_space' => $config['hosting_limit_disk_space'] ?? 0], |
||
62 | ['hosting_limit_active_courses' => $config['hosting_limit_active_courses'] ?? 0], |
||
63 | ['hosting_total_size_limit' => $_configuration['hosting_total_size_limit'] ?? 0], |
||
64 | ]; |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | |||
69 | // Format hosting limits as YAML |
||
70 | $yamlContent = "parameters:\n hosting_limits:\n urls:\n"; |
||
71 | foreach ($hostingLimits['hosting_limits']['urls'] as $urlId => $limits) { |
||
72 | $yamlContent .= " {$urlId}:\n"; |
||
73 | foreach ($limits as $limit) { |
||
74 | foreach ($limit as $key => $value) { |
||
75 | $yamlContent .= " - {$key}: {$value}\n"; |
||
76 | } |
||
77 | } |
||
78 | } |
||
79 | |||
80 | // Write hosting limits to hosting_limits.yml |
||
81 | file_put_contents($hostingLimitsFile, $yamlContent); |
||
82 | } |
||
135 |
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.