<?php
declare(strict_types=1);

namespace App\Service\Security;

use App\Test\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 UserInterface $user
     * @param UserInterface $user_to_switch
     * @return bool
     * @see SwitchUserTest::testIsAllowedToSwitch()
     */
    public function isAllowedToSwitch(UserInterface $user, UserInterface $user_to_switch): bool
    {
        return $user->getChildren()->contains($user_to_switch);
    }
}
