PHP code quality toolkit — CRAP metrics, duplication detection, mutation testing and offline UML.
Русский · Quick start · Full reference · License
ub-cdmu-php is a standalone Composer toolkit for inspecting PHP code quality. The core checks parse source code without loading or executing it, combining cyclomatic complexity and existing PHPUnit Clover line coverage with structural duplication detection. Optional tools run mutation tests using Infection or generate a self-contained offline UML viewer. Python and Docker are not required.
| Command | Purpose |
|---|---|
check |
Run CRAP and DRY analysis together |
crap |
Calculate complexity-based CRAP metrics using available coverage |
dry |
Find candidates for structural code duplication |
doctor |
Validate configuration and inspect optional tools |
mutate |
Explicitly run optional Infection mutation analysis |
uml |
Generate an offline HTML code structure viewer |
Results are evidence, not guesses: missing coverage is reported as unknown, never as a verified CRAP pass. DRY matches require developer review. By default, check only runs CRAP and DRY.
- PHP 8.4.27+ (<8.5) or 8.5.12+ (<9.0).
- Composer and PHP extensions DOM, JSON, mbstring, PCNTL and POSIX.
- Optional: an existing PHPUnit Clover coverage report, Git for
--changed, and a compatible locally installed Infection formutate.
Until the package is published, register a local checkout as a Composer path repository from the target PHP project:
composer config repositories.ub-cdmu-php path /path/to/ub-cdmu-php
composer require --dev yatseck-k/ub-cdmu-php:@dev
vendor/bin/ub-php doctor
vendor/bin/ub-php checkThe project should contain an .ub-mode.yaml file or a src/ or app/ directory. Reports are saved to .metrics/ by default.
vendor/bin/ub-php check --format json
vendor/bin/ub-php check --changed
vendor/bin/ub-php dry --threshold 0.8
vendor/bin/ub-php doctor --tools --format json
# Optional: runs the target project's tests using installed Infection
vendor/bin/ub-php mutate --changed --min-msi 80
# Creates .metrics/uml.html — open it in a browser
vendor/bin/ub-php uml--changed requires Git and is not supported for uml. Use --verbose for details or --progress never for quiet output. Optional tools are never installed automatically.
- Getting started · По-русски
- CLI, metrics, statuses, exit codes and architecture · По-русски
- Example configuration
composer install
composer test
composer test-consumer
php bin/ub-php --root fixtures check --format json- ub-mode-php — independent agent skill that can optionally use this toolkit.
- commit-rules — independent Conventional Commits skill.
MIT.