MAX_PER_CODE
MAX_PER_CODE = 50
Findings retained per code before the oldest is dropped.
A health ledger held in process memory.
This is the ledger a single run uses: a cron sweep that records what it found, decides what to do about it and reports at the end, all inside one request. It keeps no state between processes, which makes it the right thing for tests and for a one-shot sweep and the wrong thing for anything that has to remember across a deploy.
What it does share with a durable ledger is the bound. Retention is capped per code, at MAX_PER_CODE by default, for the same reason Finding clamps its context: the unbounded field here is scope - every frame hash is a new one - and a code that flaps produces a new scope on every pass. Trusting a purge to run is how a table nobody looks at becomes the largest thing in the database. When the cap is reached the oldest finding for that code is dropped, because the most recent occurrences are the ones that describe what is happening now.
__construct(int $maxPerCode = \self::MAX_PER_CODE, callable|null $clock = null) : mixed
Constructs the ledger.
| int | $maxPerCode | Findings retained per code. |
| callable|null | $clock | Returns a unix timestamp as an int. NULL uses time(). |
When $maxPerCode is below 1, which would make record() a no-op that still reported success.
rungFor(string $code) : string
The rung a code currently sits at.
With no rung set explicitly, the answer is derived from the worst severity recorded for the code, so a caller that has only ever recorded findings still gets a usable starting rung instead of having to seed one first. A code with nothing recorded sits at the bottom.
| string | $code | The finding code. |
A rung name from RepairLadder::RUNGS.
setRung(string $code, string $rung) : void
Moves a code to a rung.
An unknown rung is refused rather than stored, because RepairLadder ranks a name it does not know as UNRANKED and isAutomatic() then refuses it forever - a typo would quietly park the code where no repair ever runs.
| string | $code | The finding code. |
| string | $rung | A rung name from RepairLadder::RUNGS. |
settle(string $code, array $kept) : void
Writes back what is left of a code's findings, forgetting the code when nothing is.
The rung goes with the last finding. A code with nothing outstanding is one the caller has stopped tracking, which is the same thing RepairLadder::decay() signals with NULL at the bottom of the ladder.
| string | $code | The finding code. |
| array | $kept | The rows that survived, in order. |