sqlLoginRequest = $sqlLoginRequest; $this->loggerInterface = $loggerInterface; } public function fetchPasswordAndDatas(string $login): array { $dataRequest = $this->sqlLoginRequest->getDatasRequest(); $login = \strtolower($login); $datas = $this->executeRequestWithLogin($dataRequest, $login); return $datas; } private function executeRequestWithLogin(string $request, string $login): array { $attempt = 0; while ($attempt < self::MAX_RETRY) { $pdo = $this->getConnection(); $query = $pdo->prepare($request); $query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]); $datas = $query->fetch(PDO::FETCH_ASSOC); $query->closeCursor(); if (false === $datas) { usleep(3000); ++$attempt; } else { break; } } if (self::MAX_RETRY === $attempt) { throw new EmptyResultException(); } return $datas; } private function getConnection(): PDO { // Appel du singleton $sqlLogin = SQLLoginConnect::getInstance(); $pdo = $sqlLogin->connect($this->sqlLoginRequest->getDatabaseDsn(), $this->sqlLoginRequest->getDbUser(), $this->sqlLoginRequest->getDbPassword()); return $pdo; } }