<?php

namespace SugarCalendarBookings\Support\Blocks;

use WP_Block;

/**
 * Abstract Block.
 *
 * Base class for all Gutenberg blocks in the plugin.
 *
 * @since 1.0.0
 */
abstract class AbstractBlock {

	/**
	 * Register the block.
	 *
	 * @since 1.0.0
	 */
	abstract public function register(): void;

	/**
	 * Display the block.
	 *
	 * @since 1.0.0
	 *
	 * @param array    $attributes Block attributes.
	 * @param string   $content    Block default content.
	 * @param WP_Block $block      Block instance.
	 *
	 * @return string Block HTML output.
	 */
	abstract public function display( array $attributes, string $content, $block ): string;

	/**
	 * Get the block name (slug).
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	abstract public function get_block_name(): string;

	/**
	 * Enqueue block editor assets.
	 *
	 * @since 1.0.0
	 */
	public function enqueue_editor_assets(): void {
		// Default implementation - can be overridden by child classes.
	}

	/**
	 * Enqueue view assets.
	 *
	 * @since 1.0.0
	 */
	public function enqueue_view_assets(): void {
		// Default implementation - can be overridden by child classes.
	}

	/**
	 * Check if this block should be loaded.
	 *
	 * @since 1.0.0
	 *
	 * @return bool
	 */
	public function allow_load(): bool {

		return function_exists( 'register_block_type' );
	}
}
