<?php

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Controller for the Title Generator functionality
 * 
 * This controller acts as a wrapper around the API handler, maintaining separation of concerns:
 * - ApiHandler in app/api handles external API communication
 * - Controller handles business logic and coordinates between models/APIs
 */
class TitleGeneratorController
{
    /**
     * API handler instance
     * @var ContentCraftAI_TitleArticleAPI
     */
    protected $api_handler;

    /**
     * Constructor
     */
    public function __construct()
    {
        require_once CONTENT_CRAFT_AI_PLUGIN_PATH . 'app/api/title-article/api-handler.php';
        $this->api_handler = new ContentCraftAI_TitleArticleAPI();
    }

    /**
     * Generate titles based on keywords (delegates to API handler)
     * 
     * @param array $data The data containing keywords and other parameters
     * @return array Result with generated titles
     */
    public function generate_titles($data)
    {
        // Delegate to the API handler
        return $this->api_handler->generate_titles($data);
    }
}
