| Conditions | 5 |
| Paths | 8 |
| Total Lines | 84 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 55 | public static function post_autoload_dump( Event $event ) { |
||
| 56 | require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
||
| 57 | |||
| 58 | $dir = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../'; |
||
| 59 | $root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) ); |
||
| 60 | |||
| 61 | $vendor_name = strtolower( basename( $root ) ); |
||
| 62 | $partials = explode( '-', $vendor_name ); |
||
| 63 | $camel_case_partials = array(); |
||
| 64 | foreach ( $partials as $partial ) { |
||
| 65 | $camel_case_partials[] = ucfirst( strtolower( $partial ) ); |
||
| 66 | } |
||
| 67 | $camel_case = implode( '_', $camel_case_partials ); |
||
| 68 | $snake_case = implode( '_', $partials ); |
||
| 69 | |||
| 70 | $files = array( |
||
| 71 | '/wpb.php', |
||
| 72 | '/bootstrap/app.php', |
||
| 73 | '/includes/class-wpb-activator.php', |
||
| 74 | '/includes/class-wpb-deactivator.php', |
||
| 75 | '/includes/class-wpb-i18n.php', |
||
| 76 | '/includes/class-wpb-loader.php', |
||
| 77 | '/includes/class-wpb.php', |
||
| 78 | '/admin/class-wpb-admin.php', |
||
| 79 | '/admin/class-wpb-admin-menu.php', |
||
| 80 | '/admin/class-wpb-admin-submenu.php', |
||
| 81 | '/admin/partials/wpb-admin-display.php', |
||
| 82 | '/admin/css/wpb-admin.css', |
||
| 83 | '/admin/js/wpb-admin.js', |
||
| 84 | '/public/class-wpb-public.php', |
||
| 85 | '/public/partials/wpb-public-display.php', |
||
| 86 | '/public/css/wpb-public.css', |
||
| 87 | '/public/js/wpb-public.js', |
||
| 88 | '/routes/web.php', |
||
| 89 | '/routes/api.php', |
||
| 90 | '/resources/js/admin/main.js', |
||
| 91 | '/resources/js/frontend/main.js', |
||
| 92 | '/resources/js/spa/main.js', |
||
| 93 | '/src/Application.php', |
||
| 94 | '/src/helpers.php', |
||
| 95 | '/src/Support/Facades/Config.php', |
||
| 96 | '/src/Support/Facades/Route.php', |
||
| 97 | '/src/Http/Kernel.php', |
||
| 98 | '/src/Http/Events/RequestHandler.php', |
||
| 99 | '/src/Exceptions/Handler.php', |
||
| 100 | '/app/User.php', |
||
| 101 | '/app/Post.php', |
||
| 102 | '/app/Http/Controllers/ProductController.php', |
||
| 103 | '/app/Http/Middleware/AuthMiddleware.php', |
||
| 104 | '/app/Http/Middleware/VerifyCsrfToken.php', |
||
| 105 | '/app/Http/Kernel.php', |
||
| 106 | '/app/Exceptions/Handler.php', |
||
| 107 | ); |
||
| 108 | |||
| 109 | foreach ( $files as $file ) { |
||
| 110 | $file = $root . $file; |
||
| 111 | if ( file_exists( $file ) ) { |
||
| 112 | $contents = get_contents( $file ); |
||
| 113 | $contents = str_replace( 'wpb_', $snake_case . '_', $contents ); |
||
| 114 | $contents = str_replace( 'wpb', $vendor_name, $contents ); |
||
| 115 | $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
||
| 116 | $contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents ); |
||
| 117 | $contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents ); |
||
| 118 | $contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents ); |
||
| 119 | $contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents ); |
||
| 120 | $contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents ); |
||
| 121 | $contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents ); |
||
| 122 | $contents = str_replace( 'WPB', $camel_case, $contents ); |
||
| 123 | put_contents( |
||
| 124 | $file, |
||
| 125 | $contents |
||
| 126 | ); |
||
| 127 | |||
| 128 | $dir = dirname( $file ); |
||
| 129 | $file_name = basename( $file ); |
||
| 130 | $new_file_name = str_replace( 'wpb', $vendor_name, $file_name ); |
||
| 131 | |||
| 132 | if ( $file_name !== $new_file_name ) { |
||
| 133 | rename( $file, $dir . '/' . $new_file_name ); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | static::update_bootstrap( $root, $camel_case ); |
||
| 139 | } |
||
| 165 |
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