<?php
declare(strict_types=1);

namespace App\Service\Security;

use App\Entity\Access\Access;
use App\Tests\Service\Security\SwitchUserTest;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * Class SwitchUser : Classe gérant la possibilité de Switcher entre utilisateurs.
 * @package App\Service\Security
 */
class SwitchUser
{
    /**
     * @param Access $access
     * @param UserInterface $user_to_switch
     * @return bool
     * @see SwitchUserTest::testIsAllowedToSwitch()
     */
    public function isAllowedToSwitch(Access $access, UserInterface $user_to_switch): bool
    {

        return $access->getChildren()->contains($user_to_switch);
    }
}
