Conditions | 14 |
Paths | 195 |
Total Lines | 47 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
18 | /** |
||
19 | * @param string $package_name |
||
20 | * @param string $package_dir |
||
21 | * @param string $target_dir |
||
22 | * @param string[][] $includes_map |
||
23 | */ |
||
24 | static function run ($package_name, $package_dir, $target_dir, &$includes_map) { |
||
25 | self::save_content( |
||
26 | self::get_content( |
||
27 | self::get_files($package_name), |
||
28 | $package_name, |
||
29 | $package_dir, |
||
30 | $target_dir |
||
31 | ), |
||
32 | $package_name, |
||
33 | $target_dir, |
||
34 | $includes_map |
||
35 | ); |
||
36 | } |
||
37 | /** |
||
38 | * @param string $package_name |
||
39 | * |
||
40 | * @return string[] |
||
41 | */ |
||
42 | protected static function get_files ($package_name) { |
||
43 | $Config = Config::instance(); |
||
44 | $files = []; |
||
45 | foreach ($Config->components['modules'] as $module_name => $module_data) { |
||
46 | if ($module_data['active'] == Config\Module_Properties::UNINSTALLED) { |
||
47 | continue; |
||
48 | } |
||
49 | if (file_exists(MODULES."/$module_name/meta.json")) { |
||
50 | $meta = file_get_json(MODULES."/$module_name/meta.json"); |
||
51 | $files[] = self::extract_files($meta, $package_name); |
||
52 | } |
||
53 | } |
||
54 | foreach ($Config->components['plugins'] as $plugin_name) { |
||
55 | if (file_exists(PLUGINS."/$plugin_name/meta.json")) { |
||
56 | $meta = file_get_json(PLUGINS."/$plugin_name/meta.json"); |
||
57 | $files[] = self::extract_files($meta, $package_name); |
||
58 | } |
||
59 | } |
||
60 | return array_unique(call_user_func_array('array_merge', $files)); |
||
61 | } |
||
62 | /** |
||
63 | * @param array $meta |
||
64 | * @param string $package_name |
||
65 | * |
||
139 |