sebastianbergmann

sebastianbergmann/complexity

PHP BSD-3-Clause Dev Tools

Library for calculating the complexity of PHP code units

1.3k stars
10 forks
active
GitHub

1.3k

Stars

10

Forks

2

Open issues

5

Contributors

6.0.0 06 Feb 2026

AI Analysis

Library for calculating cyclomatic complexity of PHP code units. It serves specialized static analysis workflows where developers need to measure code complexity programmatically as part of their quality gates and metrics pipelines. Best suited for PHP developers building linting tools, CI/CD integrations, or architectural analysis systems—not a general-purpose utility.

Dev Tools Library Discovery value: 4/10
Documentation 7/10
Activity 9/10
Community 6/10
Code quality 8/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

cyclomatic-complexity code-metrics static-analysis php-tool software-quality
Actively maintained Niche/specialized use case Production ready
Deep Analysis · Based on README and public signals
17h ago

Specialized PHP code complexity calculator used within PHPUnit ecosystem

sebastian/complexity is a focused PHP library for calculating cyclomatic and cognitive complexity metrics of code units. Built and maintained by Sebastian Bergmann (PHPUnit creator), it appears designed as a dependency for code quality tooling rather than as a standalone user-facing product. No README documentation of real adoption exists beyond ecosystem integration signals.

Origin

Created July 2020 as part of Bergmann's suite of PHP code analysis libraries. Follows the modular architecture pattern established by his earlier work (php-code-coverage, lines-of-code, comparator), each addressing a discrete analysis concern rather than competing with monolithic tools.

Growth

Repository shows stable but minimal growth (1,261 stars, 10 forks as of July 2026). Last push occurred 2026-07-08, indicating continuous maintenance. Growth trajectory appears flat, consistent with a utility library serving as a transitive dependency rather than a primary user tool. No viral adoption pattern observed.

In production

Adoption not verified. README contains only installation instructions and project description; no documentation of known users, integrations, or deployment contexts. Presence in Packagist and CI badges indicate it is packaged for distribution, but actual production usage cannot be confirmed from available metadata.

Code analysis
Architecture

README does not document internal architecture, API design, or supported complexity metrics (cyclomatic, cognitive, etc.). Appears to be a single-purpose analyzer likely parsing PHP AST, but implementation details not visible from provided documentation.

Tests

README includes codecov badge linking to coverage metrics, suggesting test infrastructure exists, but specific coverage percentage not stated in provided excerpt.

Maintenance

Last push 2026-07-08 (within 24 hours of analysis date) signals active maintenance. Repository shows CI/CD workflow badges and consistent recent activity, indicating ongoing support rather than abandonment. Maintenance appears reactive to dependencies and bug fixes rather than feature-driven.

Honest verdict

ADOPT IF: building code quality tooling in PHP and need pluggable, focused complexity metrics library; already depend on Bergmann's ecosystem. AVOID IF: seeking an end-user tool for code analysis — use PHPMetrics or integrated IDE features instead; or if primary need is comprehensive analysis beyond complexity. MONITOR IF: maintaining PHP code quality infrastructure; watch whether this library is adopted by broader ecosystem tools and whether metric definitions evolve.

Independent dimensions

Mainstream potential

2/10

Technical importance

5/10

Adoption evidence

2/10

Risks
  • Adoption not publicly documented — unclear if library is actively used downstream or primarily maintained for historical reasons.
  • Narrow scope may limit growth to specialized tooling use cases; not designed for general PHP developer workflow.
  • Dependency on PHP AST parsing means changes to PHP language features or parsing libraries could require updates.
  • Low star count relative to sibling projects (lines-of-code, environment) suggests this particular metric (complexity) may be less valued than code coverage or line counts.
  • No visible evidence of community contribution or ecosystem integration beyond Packagist; bus factor appears concentrated on original author.
Prediction

Library will likely remain a stable, slowly-maintained utility for PHP tooling authors rather than grow mainstream adoption. May see modest usage increase only if broader quality-scanning tools integrate it, but absence of documented integrations suggests this is not occurring rapidly.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
100%

Information

Language
PHP
License
BSD-3-Clause
Last updated
2d ago
Created
73mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

sebastianbergmann

sebastianbergmann/lines-of-code

A PHP library for counting lines of code in source files, used to gather code...

1.2k PHP Dev Tools
sebastianbergmann

sebastianbergmann/php-code-coverage

php-code-coverage is a specialized PHP library for collecting, processing, and...

8.9k PHP Dev Tools
sebastianbergmann

sebastianbergmann/environment

This PHP library provides utilities for detecting and handling runtime-specific...

6.8k PHP Dev Tools
sebastianbergmann

sebastianbergmann/comparator

This component provides functionality to compare PHP values for equality, with...

7.1k PHP Dev Tools
sebastianbergmann

sebastianbergmann/phpunit

PHPUnit is the de facto standard unit testing framework for PHP, implementing...

20k PHP Dev Tools
vs. alternatives
PHPMetrics

Broader static analysis tool including complexity metrics alongside other analyses; complexity appears as one metric among many. sebastian/complexity is narrower and likely used as a building block rather than end product.

PHP_CodeSniffer

Code style and quality checking tool; complexity checking is secondary feature. Different focus (lint/style vs. complexity metrics).

Psalm/PHPStan

Type checking and static analysis frameworks; complexity analysis not primary concern. Operate at different abstraction level.

lines-of-code (sibling library)

Parallel library from same author computing lines-of-code metrics. Serves adjacent code measurement concern with similar adoption pattern.

Integrated PHPUnit features

PHPUnit itself may offer basic complexity warnings; sebastian/complexity likely provides more granular, reusable metrics library.