sqlLoginRequest = $sqlLoginRequest; $this->loggerInterface = $loggerInterface; } public function fetchDatas($login): array { try { $dbh = $this->getConnection(); // forge de la requête $request = $this->sqlLoginRequest->getRequestScope(); // Préparation de la requête $query = $dbh->prepare($request); $query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]); $datas = $query->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { \Sentry\captureException($e); $this->loggerInterface->critical($e->getMessage()); throw new PDOException(); } return $datas; } public function fetchPassword($login): array|bool { try { $dbh = $this->getConnection(); $request = $this->sqlLoginRequest->getRequestPassword(); $query = $dbh->prepare($request); $query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]); $password = $query->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { $this->loggerInterface->critical($e->getMessage()); throw new PDOException(); } if ($password) { return [ $password[$this->sqlLoginRequest->getPasswordColumnName()], isset($password[$this->sqlLoginRequest->getSaltColumnName()]) ? $password[$this->sqlLoginRequest->getSaltColumnName()] : null, ]; } return false; } public function getConnection(): PDO { // Appel du singleton $sqlLogin = SQLLoginConnect::getInstance(); // Connection bdd return $sqlLogin->connect($this->sqlLoginRequest->getDatabaseDsn(), $this->sqlLoginRequest->getDbUser(), $this->sqlLoginRequest->getDbPassword()); } }