|null Null to skip recording; otherwise * fields to add to the row's result - a * note on the last row the cap admits, * so the gap after it explains itself. */ public function admit( int $agent_id, string $entity_type, DateTimeImmutable $now ): ?array { $since = $now->modify( sprintf( '-%d seconds', $this->window ) ); $recorded = $this->ledger->count_status_since( $agent_id, 'refused', $entity_type, $since ); if ( $recorded >= $this->limit ) { return null; } if ( $recorded === $this->limit - 1 ) { return array( 'further_refusals_not_recorded_until' => $now->modify( sprintf( '+%d seconds', $this->window ) )->format( 'Y-m-d H:i:s' ), ); } return array(); } }