Conditions | 8 |
Paths | 8 |
Total Lines | 54 |
Code Lines | 41 |
Lines | 0 |
Ratio | 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 |
||
48 | if (preg_match('/\.js$/', $main)) { |
||
49 | $main = substr($main, 0, -3); |
||
50 | } |
||
51 | if ($main) { |
||
52 | // There is a chance that minified file is present |
||
53 | if (file_exists("$module_dir/$main.min.js")) { |
||
54 | $paths[$module_name] = "$relative_module_dir/$main.min"; |
||
55 | } elseif (file_exists("$module_dir/$main.js")) { |
||
56 | $paths[$module_name] = "$relative_module_dir/$main"; |
||
57 | } elseif (file_exists("$module_dir/dist/$main.min.js")) { |
||
58 | $paths[$module_name] = "$relative_module_dir/dist/$main.min"; |
||
59 | } elseif (file_exists("$module_dir/dist/$main.js")) { |
||
60 | $paths[$module_name] = "$relative_module_dir/dist/$main"; |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | return $paths; |
||
65 | } |
||
66 | /** |
||
67 | * @param string $package_name |
||
68 | * @param string $package_dir |
||
69 | * @param string $target_dir |
||
70 | * @param string[][] $includes_map |
||
71 | */ |
||
72 | static function run ($package_name, $package_dir, $target_dir, &$includes_map) { |
||
73 | self::save_content( |
||
74 | self::get_content( |
||
75 | self::get_files($package_name), |
||
76 | $package_name, |
||
77 | $package_dir, |
||
78 | $target_dir |
||
79 | ), |
||
80 | $package_name, |
||
81 | $target_dir, |
||
82 | $includes_map |
||
83 | ); |
||
84 | } |
||
85 | /** |
||
86 | * @param string $package_name |
||
87 | * |
||
88 | * @return string[] |
||
89 | */ |
||
90 | protected static function get_files ($package_name) { |
||
91 | $Config = Config::instance(); |
||
92 | $files = []; |
||
93 | foreach ($Config->components['modules'] as $module_name => $module_data) { |
||
94 | if ($module_data['active'] == Config\Module_Properties::UNINSTALLED) { |
||
95 | continue; |
||
96 | } |
||
97 | if (file_exists(MODULES."/$module_name/meta.json")) { |
||
98 | $meta = file_get_json(MODULES."/$module_name/meta.json"); |
||
99 | $files[] = self::extract_files($meta, $package_name); |
||
100 | } |
||
101 | } |
||
102 | foreach ($Config->components['plugins'] as $plugin_name) { |
||
187 |