<?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\AccommodationType\Accommodation;

defined( 'ABSPATH' ) || exit;

/**
 * Accommodation capacity configuration
 */
final class AccommodationCapacity
{
    private int $mainPlaces;
    private int $extraPlaces;

    /**
     * @param int $mainPlaces The total number of main sleeping places
     * @param int $extraPlaces Specify how many extra beds or similar sleeping places can be added (e.g., sofa bed, rollaway bed). These are offered on top of the main sleeping capacity.
     */
    public function __construct(int $mainPlaces, int $extraPlaces = 0)
    {
        if ($mainPlaces < 1) {
            throw new \InvalidArgumentException("Main places must be at least 1");
        }
        if ($extraPlaces < 0) {
            throw new \InvalidArgumentException("Extra places cannot be negative");
        }

        $this->mainPlaces = $mainPlaces;
        $this->extraPlaces = $extraPlaces;
    }

    public function getMainPlaces(): int
    {
        return $this->mainPlaces;
    }

    public function getExtraPlaces(): int
    {
        return $this->extraPlaces;
    }

    public function getTotalCapacity(): int
    {
        return $this->mainPlaces + $this->extraPlaces;
    }
}
