* * @phpstan-type Result array{id: Uuid, name: string, correct: int, time: \DateInterval, corrections: float, score: float} * @phpstan-type ResultList list */ class CandidateRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Candidate::class); } public function getCandidateByHash(Season $season, string $hash): ?Candidate { try { $name = Base64::base64UrlDecode($hash); } catch (UrlException) { return null; } return $this->getEntityManager()->createQuery(<<setParameter('season', $season) ->setParameter('name', $name) ->getOneOrNullResult(); } public function save(Candidate $candidate, bool $flush = true): void { $this->getEntityManager()->persist($candidate); if ($flush) { $this->getEntityManager()->flush(); } } /** @return ResultList */ public function getScores(Quiz $quiz): array { return $this->getEntityManager()->createQuery(<<setParameter('quiz', $quiz)->getResult(); } }