added logger
This commit is contained in:
parent
9840fb50ff
commit
023a7e3668
|
@ -13,12 +13,11 @@ use PDOException;
|
|||
*/
|
||||
class DynDNSRepository
|
||||
{
|
||||
public function __construct(private DatabaseConnection $databaseConnection, private array $config, private Logger $log)
|
||||
public function __construct(
|
||||
private readonly DatabaseConnection $databaseConnection,
|
||||
private readonly Logger $logger)
|
||||
{
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "DynDNSRepository::__construct()");
|
||||
}
|
||||
|
||||
$this->logger->debug(message: "DynDNSRepository::__construct()");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,9 +28,7 @@ class DynDNSRepository
|
|||
public function delete(DynDNS $dynDNS): int
|
||||
{
|
||||
$dynDNSName = $dynDNS->getName();
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "delete($dynDNSName)");
|
||||
}
|
||||
$this->logger->debug(message: "delete($dynDNSName)");
|
||||
|
||||
$sql = "
|
||||
DELETE FROM " . DatabaseConnection::TABLE_DYNDNS . "
|
||||
|
@ -54,9 +51,7 @@ class DynDNSRepository
|
|||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "findAll()");
|
||||
}
|
||||
$this->logger->debug(message: "findAll()");
|
||||
|
||||
$dyndns = [];
|
||||
$sql = "
|
||||
|
@ -84,9 +79,8 @@ class DynDNSRepository
|
|||
*/
|
||||
public function findByName(string $name): DynDNS|bool
|
||||
{
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "findByName($name)");
|
||||
}
|
||||
$this->logger->debug(message: "findByName($name)");
|
||||
|
||||
$sql = "
|
||||
SELECT id, name, a, aaaa
|
||||
FROM " . DatabaseConnection::TABLE_DYNDNS . "
|
||||
|
@ -134,9 +128,7 @@ class DynDNSRepository
|
|||
public function insert(DynDNS $dynDNS): bool|string
|
||||
{
|
||||
$dynDNSName = $dynDNS->getName();
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "insert($dynDNSName)");
|
||||
}
|
||||
$this->logger->debug(message: "insert($dynDNSName)");
|
||||
|
||||
$sql = "
|
||||
INSERT INTO " . DatabaseConnection::TABLE_DYNDNS . " (name, a, aaaa)
|
||||
|
@ -167,9 +159,7 @@ class DynDNSRepository
|
|||
{
|
||||
$dynDNSnName = $dynDNS->getName();
|
||||
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "update($dynDNSnName)");
|
||||
}
|
||||
$this->logger->debug(message: "update($dynDNSnName)");
|
||||
|
||||
$id = $dynDNS->getId();
|
||||
$current = $this->findByID(id: $id);
|
||||
|
@ -220,9 +210,7 @@ class DynDNSRepository
|
|||
*/
|
||||
public function findByID(int $id): bool|DynDNS
|
||||
{
|
||||
if ($this->config['debug']) {
|
||||
$this->log->debug(message: "findById($id)");
|
||||
}
|
||||
$this->logger->debug(message: "findById($id)");
|
||||
|
||||
$sql = "
|
||||
SELECT id, name, a, aaaa
|
||||
|
@ -242,4 +230,4 @@ class DynDNSRepository
|
|||
exit($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue