{"id":15579264,"url":"https://github.com/andrey-tech/pdepend-summary-formatter-php","last_synced_at":"2025-04-24T01:27:26.286Z","repository":{"id":198402257,"uuid":"700784620","full_name":"andrey-tech/pdepend-summary-formatter-php","owner":"andrey-tech","description":"Tool to show software code quality metrics, measured by PHP Depend, in console and CI/CD","archived":false,"fork":false,"pushed_at":"2025-03-09T15:48:39.000Z","size":205,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T05:31:42.754Z","etag":null,"topics":["clean-code","console-application","cyclomatic-complexity","dev","halstead-complexity","maintainability-index","metrics","metrics-visualization","pdepend","php","quality"],"latest_commit_sha":null,"homepage":"https://github.com/andrey-tech/pdepend-summary-formatter-php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrey-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-05T09:37:50.000Z","updated_at":"2025-03-09T15:48:43.000Z","dependencies_parsed_at":"2023-12-10T09:28:48.212Z","dependency_job_id":"fd3cc5be-137b-4b80-aaf9-a2ce6883841a","html_url":"https://github.com/andrey-tech/pdepend-summary-formatter-php","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"6d8b3b0f28473f906e60e98e14c4a911ec35d5de"},"previous_names":["andrey-tech/pdepend-summary-formatter-php"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-tech%2Fpdepend-summary-formatter-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-tech%2Fpdepend-summary-formatter-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-tech%2Fpdepend-summary-formatter-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrey-tech%2Fpdepend-summary-formatter-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrey-tech","download_url":"https://codeload.github.com/andrey-tech/pdepend-summary-formatter-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250543118,"owners_count":21447838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-code","console-application","cyclomatic-complexity","dev","halstead-complexity","maintainability-index","metrics","metrics-visualization","pdepend","php","quality"],"created_at":"2024-10-02T19:14:17.823Z","updated_at":"2025-04-24T01:27:26.266Z","avatar_url":"https://github.com/andrey-tech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pdepend Summary Formatter\n\n![Pdepend Summary Formatter logo](./assets/pdepend-summary-formatter-logo.png)\n\n[![Latest Stable Version](https://poser.pugx.org/andrey-tech/pdepend-summary-formatter-php/v)](https://packagist.org/packages/andrey-tech/pdepend-summary-formatter-php)\n[![Total Downloads](https://poser.pugx.org/andrey-tech/pdepend-summary-formatter-php/downloads)](//packagist.org/packages/andrey-tech/pdepend-summary-formatter-php)\n[![PHP Version Require](https://poser.pugx.org/andrey-tech/pdepend-summary-formatter-php/require/php)](https://packagist.org/packages/andrey-tech/pdepend-summary-formatter-php)\n[![License](https://poser.pugx.org/andrey-tech/pdepend-summary-formatter-php/license)](https://packagist.org/packages/andrey-tech/pdepend-summary-formatter-php)\n\nPdepend Summary Formatter is a tool to show software code quality metrics, measured by\n[PHP Depend](https://github.com/pdepend/pdepend) (pdepend),\nin console for development and in CI/CD pipeline.\n\n## Table of contents\n\u003c!-- MarkdownTOC levels=\"1,2,3,4,5,6\" autoanchor=\"true\" autolink=\"true\" --\u003e\n\n- [Installation](#installation)\n- [Command line options](#command-line-options)\n- [Software metrics](#software-metrics)\n- [Configuration YAML file](#configuration-yaml-file)\n- [Exit codes](#exit-codes)\n- [Authors and Maintainers](#authors-and-maintainers)\n- [License](#license)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\u003ca id=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nPdepend Summary Formatter tool requires **PHP \u003e= 7.4**, \nlatest version of [PHP Depend](https://github.com/pdepend/pdepend) \nand [Composer](https://getcomposer.org/).\n\n```shell\ncomposer require --dev pdepend/pdepend:\"^2.15\"\ncomposer require --dev andrey-tech/pdepend-summary-formatter-php\n```\n\nGenerate a default config file `pdepend-summary-formatter.yml.dist` in current working directory:\n\n```shell\n./vendor/bin/pdepend-summary-formatter --init\n```\n\nThen run `PHP Depend` to scan your source PHP-code in directory `src` and generate an XML report in file `summary.xml`:\n\n```shell\n./vendor/bin/pdepend --summary-xml=summary.xml --suffix=php src\n```\n\nThen run Pdepend Summary Formatter tool to show code quality metrics,\nmeasured by PHP Depend, in console and to write results to specified text file `summary.txt`:\n\n```shell\n./vendor/bin/pdepend-summary-formatter summary.xml --output-file=summary.txt\n```\n\n\u003ca id=\"command-line-options\"\u003e\u003c/a\u003e\n## Command line options\n\n```shell\n./vendor/bin/pdepend-summary-formatter \u003cpath to pdepend file summary.xml\u003e\n```\n\nThe Pdepend Summary Formatter tool command line interface also accepts the following optional arguments:\n\n- `--init` — Will generate a default config file `pdepend-summary-formatter.yml.dist` in current working directory.\n- `--output-file=` — Write results also to the specified text file.\n- `--config-file=` — The filepath to a custom config YAML file.\n- `--ignore-red-metrics-on-exit` —  Will exit with a zero code, even \"red\" metrics exist.\n- `--ignore-yellow-metrics-on-exit` —  Will exit with a zero code, even \"yellow\" metrics exist.\n- `--no-colors` — Disable colors in console.\n\nAn example command line of Pdepend Summary Formatter tool and PHP Depend tool:\n\n```shell\n./vendor/bin/pdepend --summary-xml=./var/summary.xml --suffix=php src,tests\n./vendor/bin/pdepend-summary-formatter ./var/summary.xml --config-file=./pdepend-summary-formatter.yml --output-file=./var/summary.txt\n```\n\nAn example of output text file `summary.txt`:\n\n```text\nFILE: src/AndreyTech/Pdepend/Summary/Formatter/Colorizer.php\n+---------------------------+-----+-----+-----+-----+-----+-----+------+-----+------+\n| CLASS                     | wmc | cbo | loc | cis | nom | npm | vars | dit | nocc |\n+---------------------------+-----+-----+-----+-----+-----+-----+------+-----+------+\n| Colorizer                 | 15  | 0   | 117 | 4   | 8   | 4   | 3    | 0   | 0    |\n+---------------------------+-----+-----+-----+-----+-----+-----+------+-----+------+\n+---------------------------+----+-----+------+-------+-------+-----+------+----+-----+------+-----+----+-----+-----+-----+\n| METHOD                    | mi | ccn | ccn2 | crap0 | npath | loc | hb   | hd | hv  | he   | ht  | hi | hl  | hnd | hnt |\n+---------------------------+----+-----+------+-------+-------+-----+------+----+-----+------+-----+----+-----+-----+-----+\n| __construct               | 81 | 1   | 1    | 2     | 1     | 4   | 0.01 | 4  | 16  | 62   | 3   | 4  | 0.3 | 6   | 6   |\n| getFgTagStats             | 82 | 1   | 1    | 2     | 1     | 4   | 0.01 | 8  | 12  | 93   | 5   | 1  | 0.1 | 5   | 5   |\n| colorizeClassMetric       | 79 | 1   | 1    | 2     | 1     | 4   | 0.01 | 5  | 37  | 192  | 11  | 7  | 0.2 | 10  | 11  |\n| colorizeMethodMetric      | 79 | 1   | 1    | 2     | 1     | 4   | 0.01 | 5  | 37  | 192  | 11  | 7  | 0.2 | 10  | 11  |\n| colorize                  | 57 | 4   | 5    | 30    | 8     | 19  | 0.14 | 27 | 315 | 8517 | 473 | 12 | 0   | 32  | 63  |\n| renderTemplate            | 59 | 3   | 3    | 12    | 4     | 17  | 0.09 | 14 | 320 | 4379 | 243 | 23 | 0.1 | 25  | 69  |\n| updateFgTagStats          | 70 | 2   | 2    | 6     | 2     | 8   | 0.05 | 23 | 78  | 1813 | 101 | 3  | 0   | 13  | 21  |\n| parseConfig               | 73 | 1   | 1    | 2     | 1     | 16  | 0.03 | 7  | 96  | 660  | 37  | 14 | 0.1 | 13  | 26  |\n+---------------------------+----+-----+------+-------+-------+-----+------+----+-----+------+-----+----+-----+-----+-----+\n\n+---------------------+--------+--------+--------+--------+-----+-----+-----+-----+-----+------+------+-------+\n| PROJECT             | min mi | avg mi | max mi | std mi | noc | nom | noi | nof | nop | loc  | lloc | ncloc |\n+---------------------+--------+--------+--------+--------+-----+-----+-----+-----+-----+------+------+-------+\n| 2023-10-04T17:15:14 | 57     | 72     | 82     | 9      | 11  | 74  | 0   | 0   | 2   | 1376 | 501  | 1250  |\n+---------------------+--------+--------+--------+--------+-----+-----+-----+-----+-----+------+------+-------+\n```\n\n\u003ca id=\"software-metrics\"\u003e\u003c/a\u003e\n## Software metrics\n\n[PHP Depend](https://pdepend.org/) (pdepend) tool can generate a large set of [software metrics](https://pdepend.org/documentation/software-metrics/index.html)\nfrom a given code base. These values can be used to measure the quality of a software project \nand they help to identify that parts of an application where a refactoring should be applied.\n\nPdepend Summary Formatter tool shows only the part of software metrics, measured by PHP Depend,\nand shows them in `green`, `yellow` and `red` colors in the console,\naccording to boundaries for values, defined in configuration YAML file.\n\nThis table shows a list of the software metrics by Pdepend Summary Formatter tool\nfor entire project, classes, traits, methods. The table also shows \nthe default values for \"red\" boundaries of software metrics,\nbased on [PHP Mess Detector](https://phpmd.org/) (PHPMD) tool.\n\n| Metric | Description                                                                                                                                                                                                                      | Project | Class | Trait | Method |\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------|-------|--------|\n| avg mi | Average [Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)                                                                   | 50      |       |       |        |\n| cbo    | [Coupling Between Objects](https://phpmd.org/rules/design.html#couplingbetweenobjects)                                                                                                                                           |         | 13    | 13    |        |\n| ccn    | [Cyclomatic Complexity Number](https://phpmd.org/rules/codesize.html#cyclomaticcomplexity)                                                                                                                                       |         |       |       | 10     |\n| ccn2   | [Extended Cyclomatic Complexity Number](https://stackoverflow.com/questions/27954015/cyclomatic-complexity-and-variants)                                                                                                         |         |       |       | 10     |\n| cis    | [Class Interface Size](https://phpmd.org/rules/codesize.html#excessivepubliccount)                                                                                                                                               |         | 45    | 45    |        |\n| crap0  | [Change Risk Analysis and Predictions Index](https://www.artima.com/weblogs/viewpost.jsp?thread=210575) for 0% coverage                                                                                                          |         |       |       | 29     |\n| dit    | [Depth of Inheritance Tree](https://phpmd.org/rules/design.html#depthofinheritance)                                                                                                                                              |         | 6     |       |        |\n| hb     | [Halstead Bugs](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                      |         |       |       | ✓      |\n| hd     | [Halstead Difficulty](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                |         |       |       | ✓      |\n| he     | [Halstead Effort](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                    |         |       |       | ✓      |\n| hi     | [Halstead Intelligence Content](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                      |         |       |       | ✓      |\n| hl     | [Halstead Level](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                     |         |       |       | ✓      |\n| hnd    | [Halstead Vocabulary](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                |         |       |       | ✓      |\n| hnt    | [Halstead Length](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                    |         |       |       | ✓      |\n| ht     | [Halstead Programming Time](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                          |         |       |       | ✓      |\n| hv     | [Halstead Volume](https://en.wikipedia.org/wiki/Halstead_complexity_measures)                                                                                                                                                    |         |       |       | ✓      |\n| lloc   | Logical Lines Of Code                                                                                                                                                                                                            | ✓       |       |       |        |\n| loc    | [Lines Of Code](https://phpmd.org/rules/codesize.html#excessivemethodlength)                                                                                                                                                     |         | 1000  |       | 100    |\n| max mi | Maximum of [Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)                                                                | 50      |       |       |        |\n| mi     | [Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)                                                                           |         |       |       | 50     |\n| min mi | Minimum of [Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)                                                                | 50      |       |       |        |\n| nocc   | [Number Of Child Classes](https://phpmd.org/rules/design.html#numberofchildren)                                                                                                                                                  |         | 15    |       |        |\n| ncloc  | Non Comment Lines Of Code                                                                                                                                                                                                        | ✓       |       |       |        |\n| noc    | Number Of Classes                                                                                                                                                                                                                | ✓       |       |       |        |\n| nof    | Number Of Functions                                                                                                                                                                                                              | ✓       |       |       |        |\n| noi    | Number Of Interfaces                                                                                                                                                                                                             | ✓       |       |       |        |\n| nom    | [Number Of Methods](https://phpmd.org/rules/codesize.html#toomanymethods)                                                                                                                                                        |         | 25    |       |        |\n| npm    | [Number of Public Methods](https://phpmd.org/rules/codesize.html#toomanypublicmethods)                                                                                                                                           |         | 20    | 20    |        |\n| npath  | [NPath Complexity](https://phpmd.org/rules/codesize.html#npathcomplexity)                                                                                                                                                        |         |       |       | 200    |\n| nop    | Number of Packages (namespaces)                                                                                                                                                                                                  | ✓       |       |       |        |\n| std mi | [Standard deviation](https://en.wikipedia.org/wiki/Standard_deviation) of [Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022) | ✓       |       |       |        |\n| vars   | [Number of Properties](https://phpmd.org/rules/codesize.html#toomanyfields)                                                                                                                                                      |         | 15    | 15    |        |\n| wmc    | [Weighted Method Count](https://phpmd.org/rules/codesize.html#excessiveclasscomplexity)                                                                                                                                          |         | 50    | 50    |        |\n\nNote: ✓ — means there are no defined \"red\" color boundaries for this metric.\n\n\u003ca id=\"configuration-yaml-file\"\u003e\u003c/a\u003e\n## Configuration YAML file\n\nBy default Pdepend Summary Formatter tool is looking for following configuration YAML files is current working directory:\n- `pdepend-summary-formatter.yml`,\n- `pdepend-summary-formatter.yml.dist`.\n\nConfiguration YAML file allows to set color boundaries for values of software metrics.\n\nPdepend Summary Formatter tool currently defines three color boundaries:\n\n| Color    | Description |\n|----------|-------------|\n| `green`  | Ok          |\n| `yellow` | Warning     |\n| `red`    | Error       |\n\nA white value means there are no defined color boundaries for this metric.\n\n\u003e You can also add/set custom colors and styles.\n\u003e See [How to Color and Style the Console Output](https://symfony.com/doc/current/console/coloring.html) in Symfony console.\n\nFragment of default configuration file:  \n```yaml\n  metrics:\n\n    # Metrics of class\n    class:\n\n      # https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-class-coupling?view=vs-2022\n      # https://phpmd.org/rules/design.html#couplingbetweenobjects\n      # https://pdepend.org/documentation/software-metrics/coupling-between-objects.html\n      cbo:\n        green: [ 0, 13 ],\n        red+bold: [ 14, null ]\n\n    # Metrics of method\n    method:\n\n      # https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-cyclomatic-complexity?view=vs-2022\n      # https://phpmd.org/rules/codesize.html#cyclomaticcomplexity\n      ccn:\n        green: [ 1, 7 ]\n        yellow+bold: [ 8, 10 ]\n        red+bold: [ 11, null ]\n```\n\n\u003ca id=\"exit-codes\"\u003e\u003c/a\u003e\n## Exit codes\n\nPdepend Summary Formatter tool currently defines four different exit codes:\n\n| Code | Description                                                                                                                       |\n|------|-----------------------------------------------------------------------------------------------------------------------------------|\n| 0    | This exit code indicates that everything worked as expected without \"red\" or \"yellow\" metrics.                                    |\n| 1    | This exit code indicates that an error/exception occurred which has interrupted tool during execution.                            |\n| 2    | This exit code means that tool has processed the summary file without the occurrence of an error/exception with \"red\" metrics.    |\n| 3    | This exit code means that tool has processed the summary file without the occurrence of an error/exception with \"yellow\" metrics. |\n\n\u003ca id=\"authors-and-maintainers\"\u003e\u003c/a\u003e\n## Authors and Maintainers\n\nThe author and maintainer of Pdepend Summary Formatter tool is [andrey-tech](https://github.com/andrey-tech).\n\n\u003ca id=\"license\"\u003e\u003c/a\u003e\n## License\n\nThis tool is licensed under the [MIT license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrey-tech%2Fpdepend-summary-formatter-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrey-tech%2Fpdepend-summary-formatter-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrey-tech%2Fpdepend-summary-formatter-php/lists"}