<?php
/**
 * Database query helpers.
 *
 * @package SEOvaultSEO
 */

namespace SEOvaultSEO\Utils;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Shared helpers for safely constructing prepared SQL fragments.
 */
final class Db {

	/**
	 * Build placeholders for an SQL IN list.
	 *
	 * The returned fragment contains placeholders only. Callers must pass the
	 * same values to `$wpdb->prepare()` in the matching placeholder order.
	 *
	 * @param array  $values      Values that will be passed to prepare().
	 * @param string $placeholder Placeholder type: %d, %f, or %s.
	 * @return string Comma-separated placeholders, or an empty string.
	 */
	public static function prepare_in_list( array $values, $placeholder = '%d' ) {
		if ( empty( $values ) || ! in_array( $placeholder, array( '%d', '%f', '%s' ), true ) ) {
			return '';
		}

		return implode( ', ', array_fill( 0, count( $values ), $placeholder ) );
	}
}
