%s)'; /** * Test the half-open validity interval [valid_from, expires_at). * * @param array $record Memory record. * @param string|null $now UTC timestamp for deterministic proof. */ public static function is_live( array $record, ?string $now = null ): bool { $now ??= gmdate( 'Y-m-d H:i:s' ); return empty( $record['deleted_at'] ) && ( empty( $record['valid_from'] ) || (string) $record['valid_from'] <= $now ) && ( empty( $record['expires_at'] ) || (string) $record['expires_at'] > $now ); } }