changed params from array to Nameserver

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-06 17:42:01 +01:00
parent b862611433
commit b2452d349a

View File

@ -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());