<?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\Security\Voter;

use Chill\TicketBundle\Entity\Ticket;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;

/**
 * Check permission on Ticket.
 */
final class TicketVoter extends Voter
{
    public const WRITE = 'CHILL_TICKET_TICKET_WRITE';
    public const READ = 'CHILL_TICKET_TICKET_READ';

    private const ALL = [self::WRITE, self::READ];

    protected function supports(string $attribute, $subject): bool
    {
        return $subject instanceof Ticket && in_array($attribute, self::ALL, true);
    }

    protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
    {
        return true;
    }
}
