Conditions | 11 |
Paths | 16 |
Total Lines | 55 |
Code Lines | 32 |
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 |
||
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 | ]); |
||
41 | |||
42 | // Ensure the hosting_limits.yml file exists |
||
43 | $hostingLimitsFile = $rootPath.'/config/hosting_limits.yml'; |
||
44 | $hostingLimits = ['hosting_limits' => ['urls' => []]]; |
||
45 | |||
46 | // Prepare hosting limits |
||
47 | if (\is_array($_configuration)) { |
||
48 | foreach ($_configuration as $key => $config) { |
||
49 | if (is_numeric($key) && \is_array($config)) { |
||
50 | // Handle configurations specific to URL IDs |
||
51 | $hostingLimits['hosting_limits']['urls'][$key] = [ |
||
52 | ['hosting_limit_users' => $config['hosting_limit_users'] ?? 0], |
||
53 | ['hosting_limit_teachers' => $config['hosting_limit_teachers'] ?? 0], |
||
54 | ['hosting_limit_courses' => $config['hosting_limit_courses'] ?? 0], |
||
55 | ['hosting_limit_sessions' => $config['hosting_limit_sessions'] ?? 0], |
||
56 | ['hosting_limit_disk_space' => $config['hosting_limit_disk_space'] ?? 0], |
||
57 | ['hosting_limit_active_courses' => $config['hosting_limit_active_courses'] ?? 0], |
||
58 | ['hosting_total_size_limit' => $_configuration['hosting_total_size_limit'] ?? 0], |
||
59 | ]; |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | |||
64 | // Format hosting limits as YAML |
||
65 | $yamlContent = "parameters:\n hosting_limits:\n urls:\n"; |
||
66 | foreach ($hostingLimits['hosting_limits']['urls'] as $urlId => $limits) { |
||
67 | $yamlContent .= " {$urlId}:\n"; |
||
68 | foreach ($limits as $limit) { |
||
69 | foreach ($limit as $key => $value) { |
||
70 | $yamlContent .= " - {$key}: {$value}\n"; |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | |||
75 | // Write hosting limits to hosting_limits.yml |
||
76 | file_put_contents($hostingLimitsFile, $yamlContent); |
||
77 | } |
||
130 |
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.