<?php
namespace boru\ai\Tests\Fakes;

use boru\ai\Conversation\Conversation;
use boru\ai\Conversation\ConversationReference;
use boru\ai\Conversation\Turn;
use boru\ai\Persistence\PersistenceProviderInterface;

class FakePersistenceProvider implements PersistenceProviderInterface
{
    /** @var Conversation|false */
    public $loadedConversation = false;

    /** @var Conversation[] */
    public $savedConversations = array();

    /** @var Turn[] */
    public $savedTurns = array();

    public function loadConversation(ConversationReference $reference)
    {
        return $this->loadedConversation;
    }

    public function saveConversation(Conversation $conversation)
    {
        $this->savedConversations[] = clone $conversation;
        return $conversation;
    }

    public function saveTurn(Conversation $conversation, Turn $turn)
    {
        $this->savedTurns[] = clone $turn;
        return $turn;
    }
}
