<?php
/**
 * BookiFlex Cart Extension
 *
 * @package    BookiFlex
 * @subpackage Cart
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */


declare(strict_types=1);
namespace BookiFlex\Extensions\Cart\Contract;

defined( 'ABSPATH' ) || exit;

/**
 * Interface for processing different types of cart items
 */
interface CartItemProcessorInterface
{
    /**
     * Create item from request data
     */
    public function createItem(array $data): CartItemInterface;

    /**
     * Validate item (availability, business rules, etc.)
     */
    public function validate(CartItemInterface $item, int $quantity = 1): bool;

    /**
     * Get validation errors as associative array
     *
     * @return array<string, string> Associative array where key is error code and value is error message
     */
    public function getValidationErrors(): array;

    /**
     * Process item (calculate prices, apply taxes, etc.)
     */
    public function process(CartItemInterface $item): CartItemInterface;

    /**
     * Check availability for the item
     */
    public function checkAvailability(CartItemInterface $item, int $quantity): bool;

    /**
     * Calculate and set latest price for the item
     */
    public function calculateItemTotal(CartItemInterface $item): CartItemInterface;
}
