limits; } /** * Refuse a create when the stored count is already at the ceiling. * * @param EditionDimension $dimension Dimension. * @param int $current_count Non-deleted rows. * * @throws EditionLimitReached When at capacity. */ public function assert_can_create( EditionDimension $dimension, int $current_count ): void { if ( $this->limits->allows_another( $dimension, $current_count ) ) { return; } // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- edition ceiling, not HTML output. throw new EditionLimitReached( $dimension, $this->limits->max( $dimension ) ); } /** * Clamp a seed target for a table key. * * @param string $table_key Repository table key (`services`, `agents`, …). * @param int $desired Requested count. */ public function cap_target( string $table_key, int $desired ): int { $dimension = match ( $table_key ) { 'services' => EditionDimension::Service, 'agents' => EditionDimension::Agent, 'locations' => EditionDimension::Location, 'booking_forms' => EditionDimension::BookingForm, default => null, }; if ( null === $dimension ) { return max( 0, $desired ); } return $this->limits->cap( $dimension, $desired ); } }