リファクタリングに適した候補を発見するのに役立ちます。
churn-phpは、プロジェクト内でリファクタリングの候補となる php ファイルを特定するのに役立つパッケージです。指定されたパス内の各 PHP ファイルを検査し、次のことを行います。
結果は表に表示されます。

変更が多く、複雑性が高いファイルは、変更が少なく、複雑性が低いファイルよりもリファクタリングの対象となる可能性があります。
churn-php開発者がリファクタリングするファイルを特定するのを支援するだけです。どのファイルをリファクタリングするかを決定するには、自分自身の判断に加えて結果を使用することをお勧めします。
churn.pharの最新リリースをダウンロードするか、Phive を使用してインストールします。
phive install churn Composer 経由でchurn-phpインストールすることもできます。
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
churnオプションで churn-php の設定に使用できるchurn.ymlファイルを追加できます。このファイルの場所は、 --configurationオプションを使用してカスタマイズできます。
# Default: "churn.yml" or "churn.yml.dist"
churn run --configuration=config-dir/ < path >
churn run --configuration=my-config.yml < path >サンプルchurn.ymlファイルは次のようになります。
# The maximum number of files to display in the results table.
# Default: 10
filesToShow : 10
# The minimum score a file need to display in the results table.
# Disabled if null.
# Default: 0.1
minScoreToShow : 0
# The command returns an 1 exit code if the highest score is greater than the threshold.
# Disabled if null.
# Default: null
maxScoreThreshold : 0.9
# The number of parallel jobs to use when processing files.
# Default: 10
parallelJobs : 10
# How far back in the VCS history to count the number of commits to a file
# Can be a human readable date like 'One week ago' or a date like '2017-07-12'
# Default: '10 Years ago'
commitsSince : One year ago
# Files to ignore when processing. The full path to the file relative to the root of your project is required.
# Also supports regular expressions.
# Default: All PHP files in the path provided to churn-php are processed.
filesToIgnore :
- src/Commands/ChurnCommand.php
- src/Results/ResultsParser.php
- src/Foo/Ba*
# File extensions to use when processing.
# Default: php
fileExtensions :
- php
- inc
# This list is used only if there is no argument when running churn.
# Default: <empty>
directoriesToScan :
- src
- tests/
# List of user-defined hooks.
# They can be referenced by their full qualified class name if churn has access to the autoloader.
# Otherwise the file path can be used as well.
# See below the section about hooks for more details.
# Default: <empty>
hooks :
- NamespaceMyHook
- path/to/my-hook.php
# The version control system used for your project.
# Accepted values: fossil, git, mercurial, subversion, none
# Default: git
vcs : git
# The path of the cache file. It doesn't need to exist before running churn.
# Disabled if null.
# Default: null
cachePath : .churn.cache churn.ymlファイルが省略されている場合、または個別の設定が省略されている場合は、上記のデフォルト値が使用されます。
結果をさまざまな形式で出力するようにchurnを構成できます。使用可能な形式は次のとおりです。
csvjsonmarkdowntext (デフォルト)別の形式を使用するには、 --formatオプションを使用します。 jsonのコマンド例:
churn run --format jsonフック設定を使用すると、 churnカスタマイズできます。
ユーザー定義のフックは、少なくとも 1 つのフック インターフェイスを実装する必要があります。
| フックインターフェース | 対応するイベントインターフェース |
|---|---|
| 分析後フック | 分析後 |
| ファイル分析フック後 | ファイル分析後 |
| 分析前フック | 分析前 |
ご質問、コメント、フィードバックはありますか? @bmitch2112
composer testを実行し、合格することを確認してください。MIT ライセンス (MIT)。詳細については、ライセンス ファイルを参照してください。