<?php
/**
 * Result for saved-product bulk updates.
 *
 * @package Affilun\Application\Product\UseCase
 */

declare(strict_types=1);

namespace Affilun\Application\Product\UseCase;

use Affilun\Infrastructure\Persistence\ProductRecord;

/**
 * Immutable bulk preview/apply result.
 */
final class BulkUpdateProductsResult {

	/**
	 * @var list<ProductRecord>
	 */
	private array $previewRecords;

	/**
	 * @param int                 $matchedCount   Matched count.
	 * @param int                 $updatedCount   Updated count.
	 * @param list<ProductRecord> $previewRecords Preview sample.
	 */
	public function __construct(
		private int $matchedCount,
		private int $updatedCount,
		array $previewRecords
	) {
		$this->previewRecords = array_values( $previewRecords );
	}

	/**
	 * Number of records matched by filters.
	 */
	public function matchedCount(): int {
		return $this->matchedCount;
	}

	/**
	 * Number of records updated. Zero for preview-only results.
	 */
	public function updatedCount(): int {
		return $this->updatedCount;
	}

	/**
	 * Preview sample records.
	 *
	 * @return list<ProductRecord>
	 */
	public function previewRecords(): array {
		return $this->previewRecords;
	}
}
