<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\TicketBundle\Service\Ticket;

use Chill\TicketBundle\Entity\Ticket;
use Chill\TicketBundle\Repository\PersonTicketACLAwareRepositoryInterface;

final readonly class SuggestPersonForTicket implements SuggestPersonForTicketInterface
{
    public function __construct(private PersonTicketACLAwareRepositoryInterface $personTicketACLAwareRepository) {}

    public function suggestPerson(Ticket $ticket, int $start = 0, int $limit = 20): array
    {
        $caller = $ticket->getCaller();
        if (null === $caller) {
            return [];
        }

        return $this->personTicketACLAwareRepository->findPersonPreviouslyAssociatedWithCaller($caller, $start, $limit);
    }
}
