Discover files in need of refactoring.
churn-php is a package that helps you identify php files in your project that could be good candidates for refactoring.
It examines each PHP file in the path it is provided and:
The results are displayed in a table:
A file that changes a lot and has a high complexity might be a better candidate for refactoring than a file that doesn't change a lot and has a low complexity.
churn-php only assists the developer to identify files for refactoring.
It's best to use the results in addition to your own judgment to decide which files you may want to refactor.
Download the last release of churn.phar
or install it with Phive:
phive install churnYou can also install churn-php via Composer:
composer require bmitch/churn-php --devchurn run <one or more paths to source code> ...
churn run src
churn run src tests
# the command name can be skipped if directoriesToScan is set in churn.yml
churnYou may add an optional churn.yml file which can be used to configure churn-php.
The location of this file can be customized using the --configuration option:
# Default: "churn.yml" or "churn.yml.dist"
churn run --configuration=config-dir/ <path>
churn run --configuration=my-config.yml <path>A sample churn.yml file looks like:
…If a churn.yml file is omitted or an individual setting is omitted the default values above will be used.
You can configure churn to output the result in different formats. The available formats are:
csvjsonmarkdowntext (default)To use a different format use --format option. Example command for json:
churn run --format jsonThe hooks configuration allows you to customize churn.
A user-defined hook must implement at least one Hook interface:
| Hook interface | Corresponding event interface |
|---|---|
| AfterAnalysisHook | AfterAnalysis |
| AfterFileAnalysisHook | AfterFileAnalysis |
| BeforeAnalysisHook | BeforeAnalysis |
Questions, comments, feedback? @bmitch2112
composer test on PHP 7.1 and ensure it passes.The MIT License (MIT). Please see License File for more information.
No open issues yet, or sync has not completed.