Skip to content
CAI
Software that uses CAICheck a score

sebastianbergmann/php-timer

71.5

Strong · 26 September 2026

607

lines of production code

PHP

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a PHP library providing high-resolution timing and resource usage measurement utilities. It exposes a Timer class with nanosecond precision, a Duration value object, and a ResourceUsageFormatter that calculates memory and time consumption relative to the start of a server request. The codebase is maintained with strict static analysis and modernized build automation using Composer and PHPUnit.

Features

Add timer-specific exception classes

The library now includes dedicated exception classes for timer-related errors: NoActiveTimerException is thrown when an operation requires an active timer but none is running, and TimeSinceStartOfRequestNotAvailableException is thrown when the time since the start of the request cannot be determined. These exceptions implement the new Exception interface, which extends PHP's Throwable, providing a structured way to handle timer-specific failures.

src/exceptions · high confidence

Added script to extract release notes from changelog

A new PHP script, \build/scripts/extract-release-notes.php\, has been added to the build tooling. This utility allows users to extract the release notes for a specific version tag from the \ChangeLog.md\ file, facilitating the automation of release processes when tags are pushed.

build · high confidence

Removals

Removal of PHP\_Timer utility class

The PHP\_Timer class has been removed from the codebase. This class previously provided static methods for timing operations, including starting/stopping timers, formatting elapsed time, and calculating resource usage based on server request time. Its removal eliminates the dependency on this specific timing utility.

PHP · high confidence

Behavioural changes

136 commits (0 fixes) modifying tools

A change to existing behaviour in tools — 136 commits, 4 files.

tools · medium confidence · unverified

Modernized build automation and dropped PEAR distribution

The project has replaced its legacy PEAR packaging with a modern Composer-based workflow, removing the \package.xml\ file entirely. Build and tool management now rely on Phive for binaries (such as PHP-CS-Fixer and PHPStan) and Composer for dependencies, orchestrated via an Ant \build.xml\ script. Configuration files for PHPStan (level 10), PHPUnit, and PHP-CS-Fixer have been added to standardize code quality checks, while \.gitattributes\ and \.gitignore\ have been updated to exclude build artifacts and tool directories from repository exports.

(repo-wide) · high confidence

Refactored timer and resource usage into dedicated value objects

The timer functionality has been restructured to improve precision and reliability. A new \Duration\ value object now encapsulates time with nanosecond granularity, replacing previous float-based calculations. The \Timer\ class now uses \hrtime()\ for high-resolution timing and returns \Duration\ objects upon stopping. Additionally, a new \ResourceUsageFormatter\ class handles the formatting of time and memory consumption, explicitly relying on \$\_SERVER\['REQUEST\_TIME\_FLOAT'\]\ for request-start time calculations and throwing a specific exception if it is unavailable, thereby removing reliance on less reliable server variables.

src · high confidence

Test coverage

Migrated timer tests to PHPUnit 10 attributes and new value objects

The test suite for the timer component has been updated to use PHPUnit 10's attribute-based syntax (e.g., \#\[CoversClass\]) instead of legacy annotations, and the data provider methods are now static. The old \Tests/TimerTest.php\ file was removed and replaced with new tests in the \tests/\ directory that cover the new \Duration\ and \ResourceUsageFormatter\ classes, ensuring correct formatting of time and memory usage, including edge cases where \$\_SERVER\['REQUEST\_TIME\_FLOAT'\]\ is unavailable.

Tests · high confidence

Dependencies

PHPStan static analysis tooling upgraded to version 2.2.16 with strict rules

The local PHP development environment now uses PHPStan 2.2.16, upgraded from previous minor versions, alongside phpstan-strict-rules 2.0.12 and ergebnis/phpstan-rules 2.14.0. This update brings stricter static analysis checks to the codebase, including new rules for named arguments and parameter handling, and ensures compatibility with PHP 8.6.

tools/.phpstan · high confidence

Update PHPStan and PHPUnit dependencies to latest versions

The project's \composer.json\ and the isolated PHPStan tooling manifest (\tools/.phpstan/composer.json\) have been updated to use the latest major versions of their development dependencies. Specifically, \phpunit/phpunit\ is now constrained to \^13.3.5\ and \phpstan/phpstan\ to \^2.2.16\, along with their respective extensions (\phpstan-strict-rules\, \ergebnis/phpstan-rules\). This ensures that static analysis and testing run against the most recent tooling versions, which may include new features, bug fixes, or breaking changes in the analysis engine itself.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 51 → 72 (+20.3)
  • Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 100 → 100 (+0.0)
  • Architecture 69 → 69 (+0.0)
  • Maturity 59 → 66 (+6.6)
  • Readiness 32 → 78 (+45.9)
  • Security 81 → 88 (+6.3)

Resolved (5)

  • Coverage not measured — test suite did not build
  • Dimension evaluation failed
  • No exposed public API
  • No tests found
  • Test reliability not included

Changes since last survey

  • 20 commits — 20 feature/other, 0 fixes

By area

  • tools/.phpstan — 10 commits
  • (root) — 7 commits
  • .github/workflows — 2 commits
  • (repo) — 1 commit

Notable commits

  • change: Do not depend on tomasvotruba/type-coverage
  • change: Do not perform lock-file maintenance
  • change: Merge branch '8.0'
  • change: Update PHPStan packages
  • change: Update codecov/codecov-action action to v7.1.0
  • change: Update codecov/codecov-action action to v7.1.1
  • change: Update dependency phpstan/phpstan to ^2.2.10
  • change: Update dependency phpstan/phpstan to ^2.2.11
  • change: Update dependency phpstan/phpstan to ^2.2.12
  • change: Update dependency phpstan/phpstan to ^2.2.13
  • change: Update dependency phpstan/phpstan to ^2.2.14
  • change: Update dependency phpstan/phpstan to ^2.2.9
  • change: Update dependency phpstan/phpstan to ^2.2.9
  • change: Update dependency phpunit/phpunit to ^13.3.0
  • change: Update dependency phpunit/phpunit to ^13.3.1
  • change: Update dependency phpunit/phpunit to ^13.3.2
  • change: Update dependency phpunit/phpunit to ^13.3.3
  • change: Update dependency phpunit/phpunit to ^13.3.4
  • change: Update dependency phpunit/phpunit to ^13.3.5
  • change: Update tools

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

sebastianbergmann/php-timer was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 26 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit a5971bced5216cf3f3767b433adc0ca00a1422d4 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-a15879f6f801.