<?php

namespace App\Game\Repository;

use App\Game\Entity\Game;
use App\Game\Entity\GameSetting;
use App\Game\Enum\GameSettingType;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<GameSetting>
 */
class GameSettingRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, GameSetting::class);
    }

    public function getSetting(Game $game, GameSettingType $name): ?GameSetting
    {
        return $this->findOneBy([
            'game' => $game,
            'name' => $name,
        ]);
    }
}
