From 9562a7d0bb9cd2107fa31466cae5ad4c9c4444e3 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 25 Nov 2024 16:09:47 +0200 Subject: [PATCH] Adds phpdoc comments --- app/classes/database.php | 3 ++- app/classes/host.php | 47 ++++++++++++++++++++++++++++++++++++---- app/classes/log.php | 3 ++- app/classes/server.php | 3 ++- app/classes/user.php | 3 ++- 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/app/classes/database.php b/app/classes/database.php index 00b9b39..1c0e314 100644 --- a/app/classes/database.php +++ b/app/classes/database.php @@ -2,11 +2,12 @@ /** * Class Database + * * Manages database connections for SQLite and MySQL (or MariaDB). */ class Database { /** - * @var PDO|null $pdo The PDO instance representing the database connection. + * @var PDO|null $pdo The database connection instance. */ private $pdo; diff --git a/app/classes/host.php b/app/classes/host.php index ed1f834..11807bb 100644 --- a/app/classes/host.php +++ b/app/classes/host.php @@ -1,13 +1,33 @@ db = $database->getConnection(); } - // get details of a specified host ID (or all) in a specified platform ID + /** + * Get details of a specified host ID (or all hosts) in a specified platform ID. + * + * @param string $platform_id The platform ID to filter the hosts by (optional). + * @param string $host_id The host ID to filter the details (optional). + * + * @return array The details of the host(s) in the form of an associative array. + */ public function getHostDetails($platform_id = '', $host_id = '') { $sql = 'SELECT id, @@ -41,7 +61,13 @@ class Host { } - // add new host + /** + * Add a new host to the database. + * + * @param array $newHost An associative array containing the details of the host to be added. + * + * @return bool True if the host was added successfully, otherwise false. + */ public function addHost($newHost) { try { $sql = 'INSERT INTO hosts @@ -64,7 +90,14 @@ class Host { } } - // edit an existing host + /** + * Edit an existing host in the database. + * + * @param string $platform_id The platform ID to which the host belongs. + * @param array $updatedHost An associative array containing the updated details of the host. + * + * @return bool True if the host was updated successfully, otherwise false. + */ public function editHost($platform_id, $updatedHost) { try { $sql = 'UPDATE hosts SET @@ -90,7 +123,13 @@ class Host { } - // delete a host + /** + * Delete a host from the database. + * + * @param int $host_id The ID of the host to be deleted. + * + * @return bool True if the host was deleted successfully, otherwise false. + */ public function deleteHost($host_id) { try { $sql = 'DELETE FROM hosts diff --git a/app/classes/log.php b/app/classes/log.php index dbf8626..bb5fb2a 100644 --- a/app/classes/log.php +++ b/app/classes/log.php @@ -2,11 +2,12 @@ /** * Class Log + * * Handles logging events into a database and reading log entries. */ class Log { /** - * @var PDO $db The database connection instance. + * @var PDO|null $db The database connection instance. */ private $db; diff --git a/app/classes/server.php b/app/classes/server.php index 64ada38..eb958a6 100644 --- a/app/classes/server.php +++ b/app/classes/server.php @@ -2,11 +2,12 @@ /** * Class Server + * * Handles server-related operations, including retrieving server status. */ class Server { /** - * @var PDO|null The database connection instance. + * @var PDO|null $db The database connection instance. */ private $db; diff --git a/app/classes/user.php b/app/classes/user.php index fdb3fea..ba361ac 100644 --- a/app/classes/user.php +++ b/app/classes/user.php @@ -2,11 +2,12 @@ /** * Class User + * * Handles user-related functionalities such as registration, login, rights management, and profile updates. */ class User { /** - * @var PDO Database connection instance. + * @var PDO|null $db The database connection instance. */ private $db;