<?php

namespace ZenoChatbot\Services\Indexing\Strategies;

use ZenoChatbot\Services\Indexing\Contracts\IndexStrategyInterface;
use ZenoChatbot\Services\Indexing\Engine\KnowledgeNotesIndexEngine;

class KnowledgeNoteIndex implements IndexStrategyInterface
{
    /** @var string */
    private $content;

    public function __construct(string $content = '')
    {
        $this->content = $content;
    }

    public function key(): string
    {
        return 'knowledge_notes';
    }

    public function index(): array
    {
        return KnowledgeNotesIndexEngine::saveContent($this->content);
    }

    public function get(): array
    {
        return [
            'success' => true,
            'data' => [
                'content' => KnowledgeNotesIndexEngine::getContent(),
            ],
        ];
    }

    public function clear(): array
    {
        return KnowledgeNotesIndexEngine::clearIndex();
    }

    public function stats(): array
    {
        return KnowledgeNotesIndexEngine::getStats();
    }
}
