|
| 1 | +# example-php |
| 2 | + |
| 3 | +[](https://demo.coveragetracker.dev/CoverageTracker/example-php?metric=coverage) |
| 4 | +[](https://demo.coveragetracker.dev/CoverageTracker/example-php?metric=complexity) |
| 5 | + |
| 6 | +A small, idiomatic PHP invoicing library used as the PHP reference example |
| 7 | +for [Coverage Tracker](https://coveragetracker.dev). It exists to give the |
| 8 | +PHP row in the |
| 9 | +[coverage report generation guide](https://coveragetracker.dev/docs/generating-coverage-reports) |
| 10 | +a live, working reference, and to populate the |
| 11 | +[demo dashboard](https://demo.coveragetracker.dev) with real trend data. |
| 12 | + |
| 13 | +**This is a demo/marketing repo, not a test suite for Coverage Tracker |
| 14 | +itself.** |
| 15 | + |
| 16 | +## What's here |
| 17 | + |
| 18 | +- `src/` — `Money` (integer-cents value object), `Discount` (percentage/fixed, |
| 19 | + promo-code lookup), `TaxCalculator` (tiered jurisdiction rates with a |
| 20 | + de-minimis exemption), `LineItem`, and `Invoice`, each with real branching |
| 21 | + logic. |
| 22 | +- `tests/` — a [PHPUnit](https://phpunit.de) suite with several deliberately |
| 23 | + uncovered branches (unknown promo codes, unknown tax jurisdictions, |
| 24 | + guard-clause validation), so `branch_coverage < line_coverage` shows up on |
| 25 | + the dashboard. |
| 26 | +- `.github/workflows/coverage.yml` — runs the suite under PHPUnit with |
| 27 | + Xdebug's path-coverage mode, generates a |
| 28 | + [Lizard](https://github.com/terryyin/lizard) complexity report, then |
| 29 | + reports both to the demo instance via the `coverage-tracker` reporting |
| 30 | + Action with `coverage-tool: phpunit` (Cobertura's XML shape doesn't |
| 31 | + self-identify its generator, so the reporter needs to be told to trust |
| 32 | + `branch-rate`). |
| 33 | + |
| 34 | +## Running locally |
| 35 | + |
| 36 | +```sh |
| 37 | +composer install |
| 38 | +XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-cobertura=coverage.xml # writes coverage.xml |
| 39 | +python -m lizard src --xml > lizard-report.xml |
| 40 | +``` |
| 41 | + |
| 42 | +`phpunit.xml` sets `<coverage pathCoverage="true"/>` — Xdebug only emits |
| 43 | +branch data when path coverage is requested; without it PHPUnit's Cobertura |
| 44 | +report always writes `branch-rate="0"`. |
0 commit comments