Conditions | 5 |
Paths | 8 |
Total Lines | 100 |
Code Lines | 84 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | 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 |
||
56 | public static function post_autoload_dump(Event $event) |
||
57 | { |
||
58 | require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php'; |
||
59 | |||
60 | $dir = $event->getComposer()->getConfig()->get('vendor-dir').'/../'; |
||
61 | $root = dirname($event->getComposer()->getConfig()->get('vendor-dir')); |
||
62 | |||
63 | $vendor_name = strtolower(basename($root)); |
||
64 | $partials = explode('-', $vendor_name); |
||
65 | $camel_case_partials = []; |
||
66 | foreach ($partials as $partial) { |
||
67 | $camel_case_partials[] = ucfirst(strtolower($partial)); |
||
68 | } |
||
69 | $camel_case = implode('_', $camel_case_partials); |
||
70 | $snake_case = implode('_', $partials); |
||
71 | |||
72 | $files = [ |
||
73 | '/admin/class-wpb-admin.php', |
||
74 | '/admin/class-wpb-admin-menu.php', |
||
75 | '/admin/class-wpb-admin-submenu.php', |
||
76 | '/admin/partials/wpb-admin-display.php', |
||
77 | '/admin/css/wpb-admin.css', |
||
78 | '/admin/js/wpb-admin.js', |
||
79 | '/app/Exceptions/Handler.php', |
||
80 | '/app/Http/Controllers/ProductController.php', |
||
81 | '/app/Http/Middleware/AuthMiddleware.php', |
||
82 | '/app/Http/Middleware/VerifyCsrfToken.php', |
||
83 | '/app/Http/Kernel.php', |
||
84 | '/app/User.php', |
||
85 | '/app/Post.php', |
||
86 | '/bootstrap/app.php', |
||
87 | '/config/app.php', |
||
88 | '/config/database.php', |
||
89 | '/config/view.php', |
||
90 | '/database/migrations/class-create-customers-table.php', |
||
91 | '/database/seeds/class-customers-table.php', |
||
92 | '/includes/class-wpb-activator.php', |
||
93 | '/includes/class-wpb-deactivator.php', |
||
94 | '/includes/class-wpb-i18n.php', |
||
95 | '/includes/class-wpb-loader.php', |
||
96 | '/includes/class-wpb.php', |
||
97 | '/public/class-wpb-public.php', |
||
98 | '/public/partials/wpb-public-display.php', |
||
99 | '/public/css/wpb-public.css', |
||
100 | '/public/js/wpb-public.js', |
||
101 | '/resources/js/admin/main.js', |
||
102 | '/resources/js/admin/router/index.js', |
||
103 | '/resources/js/frontend/main.js', |
||
104 | '/resources/js/spa/main.js', |
||
105 | '/routes/web.php', |
||
106 | '/routes/api.php', |
||
107 | '/src/Contracts/Http/Kernel.php', |
||
108 | '/src/Contracts/ExceptionHandler.php', |
||
109 | '/src/Database/Eloquent/Scopes/PostAuthorScope.php', |
||
110 | '/src/Database/Eloquent/Scopes/PostStatusScope.php', |
||
111 | '/src/Database/Eloquent/Scopes/PostTypeScope.php', |
||
112 | '/src/Database/DB.php', |
||
113 | '/src/Exceptions/Handler.php', |
||
114 | '/src/Http/Events/RequestHandled.php', |
||
115 | '/src/Http/Kernel.php', |
||
116 | '/src/helpers.php', |
||
117 | '/src/Support/Facades/Config.php', |
||
118 | '/src/Support/Facades/Route.php', |
||
119 | '/src/Application.php', |
||
120 | '/tests/Application.php', |
||
121 | '/wpb.php', |
||
122 | ]; |
||
123 | |||
124 | foreach ($files as $file) { |
||
125 | $file = $root.$file; |
||
126 | if (file_exists($file)) { |
||
127 | $filesystem = new Filesystem(); |
||
128 | |||
129 | $contents = $filesystem->get($file); |
||
130 | $contents = str_replace('wpb_', $snake_case.'_', $contents); |
||
131 | $contents = str_replace('wpb', $vendor_name, $contents); |
||
132 | $contents = str_replace('WPB_APP_ROOT', strtoupper($camel_case).'_APP_ROOT', $contents); |
||
133 | $contents = str_replace('WPB_FILE', strtoupper($camel_case).'_FILE', $contents); |
||
134 | $contents = str_replace('WPB_PATH', strtoupper($camel_case).'_PATH', $contents); |
||
135 | $contents = str_replace('WPB_INCLUDES', strtoupper($camel_case).'_INCLUDES', $contents); |
||
136 | $contents = str_replace('WPB_URL', strtoupper($camel_case).'_URL', $contents); |
||
137 | $contents = str_replace('WPB_ASSETS', strtoupper($camel_case).'_ASSETS', $contents); |
||
138 | $contents = str_replace('WPB_VERSION', strtoupper($camel_case).'_VERSION', $contents); |
||
139 | $contents = str_replace('WPB', $camel_case, $contents); |
||
140 | $filesystem->put( |
||
141 | $file, |
||
142 | $contents |
||
143 | ); |
||
144 | |||
145 | $dir = dirname($file); |
||
146 | $file_name = basename($file); |
||
147 | $new_file_name = str_replace('wpb', $vendor_name, $file_name); |
||
148 | |||
149 | if ($file_name !== $new_file_name) { |
||
150 | rename($file, $dir.'/'.$new_file_name); |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | |||
155 | static::update_composer($filesystem, $root, $camel_case); |
||
156 | } |
||
204 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths