<?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\Admin\CPT\Event;

defined( 'ABSPATH' ) || exit;

/**
 * Event: AccommodationType was deleted
 *
 * Dispatched before an AccommodationType CPT is deleted
 *
 * This event contains a snapshot of the post data before deletion,
 * allowing subscribers to perform cleanup operations.
 *
 * This is an immediate event (not deferred) dispatched via EventDispatcher
 * before the post is actually deleted from the database.
 */
class AccommodationTypeWasDeleted
{
    /**
     * @param int $postId WordPress post ID (same as accommodationTypeId)
     * @param array $data Snapshot of post data before deletion
     */
    public function __construct(
        private readonly int $postId,
        private readonly array $data
    ) {
    }

    /**
     * Get WordPress post ID
     */
    public function getPostId(): int
    {
        return $this->postId;
    }

    /**
     * Get AccommodationType ID (same as post ID)
     */
    public function getAccommodationTypeId(): int
    {
        return $this->postId;
    }

    /**
     * Get post data snapshot
     */
    public function getData(): array
    {
        return $this->data;
    }

    /**
     * Get accommodation type name
     */
    public function getName(): string
    {
        return $this->data['name'] ?? '';
    }

    /**
     * Get available units
     */
    public function getAvailableUnits(): int
    {
        return $this->data['available_units'] ?? 0;
    }

    /**
     * Get short code
     */
    public function getShortCode(): string
    {
        return $this->data['short_code'] ?? '';
    }

    /**
     * Get accommodation category
     */
    public function getAccommodationCategory(): string
    {
        return $this->data['accommodation_category'] ?? '';
    }
}
