From b2452d349a65385d0085161bbf2719aa189ff68f Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 6 Feb 2022 17:42:01 +0100 Subject: [PATCH] changed params from array to Nameserver Signed-off-by: tracer --- src/Repository/NameserverRepository.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Repository/NameserverRepository.php b/src/Repository/NameserverRepository.php index c145cfa..3e45b8e 100644 --- a/src/Repository/NameserverRepository.php +++ b/src/Repository/NameserverRepository.php @@ -13,7 +13,8 @@ use PDOException; class NameserverRepository { public function __construct(private DatabaseConnection $databaseConnection) - {} + { + } /** @@ -93,20 +94,21 @@ class NameserverRepository /** - * @param String $name - * @param String $a - * @param String $aaaa - * @param String $apikey + * @param \App\Entity\Nameserver $nameserver * * @return string|false */ - public function insert(string $name, string $a, string $aaaa, String $apikey): bool|string + public function insert(Nameserver $nameserver): bool|string { $sql = " INSERT INTO " . DatabaseConnection::TABLE_NAMESERVERS . " (name, a, aaaa, apikey) VALUES (:name, :a, :aaaa, :apikey)"; try { + $name = $nameserver->getName(); + $a = $nameserver->getA(); + $aaaa = $nameserver->getAaaa(); + $apikey = $nameserver->getApikey(); $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->bindParam(param: ':name', var: $name); $statement->bindParam(param: ':a', var: $a); @@ -130,7 +132,7 @@ class NameserverRepository * * @return false|int */ - public function update(int $id, string $name, string $a, string $aaaa, String $apikey): bool|int + public function update(int $id, string $name, string $a, string $aaaa, string $apikey): bool|int { $current = $this->findByID(id: $id); @@ -210,7 +212,7 @@ class NameserverRepository * * @return int */ - public function getLongestEntry(String $field): int + public function getLongestEntry(string $field): int { $sql = " SELECT MAX(LENGTH(" . $field . ")) as length FROM " . DatabaseConnection::TABLE_NAMESERVERS; @@ -218,7 +220,7 @@ class NameserverRepository try { $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->execute(); - $result = $statement->fetch(); + $result = $statement->fetch(); return $result['length']; } catch (PDOException $e) { exit($e->getMessage());