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


declare(strict_types=1);
namespace BookiFlex\Core\Model\DateUnit\Calculator;

use BookiFlex\Core\Model\DateUnit\Calculator\Strategy\StandardPriceCalculator;

defined( 'ABSPATH' ) || exit;

/**
 * Factory for creating calculators
 */
class PriceCalculatorFactory
{
    private array $calculators = [];

    public function __construct()
    {
        // Register standard calculators
        $this->register(new StandardPriceCalculator());
    }

    /**
     * Register calculator
     */
    public function register(PriceCalculatorInterface $calculator): void
    {
        $this->calculators[$calculator->getName()] = $calculator;
    }

    /**
     * Get calculator by name
     */
    public function get(string $name): ?PriceCalculatorInterface
    {
        return $this->calculators[$name] ?? null;
    }

    /**
     * Get default calculator
     */
    public function getDefault(): PriceCalculatorInterface
    {
        return $this->calculators['standard'] ?? new StandardPriceCalculator();
    }

    /**
     * Get list of available calculators
     */
    public function getAvailable(): array
    {
        return array_keys($this->calculators);
    }
}
