Adds phpdoc comments

main
Yasen Pramatarov 2024-11-25 16:09:47 +02:00
parent 51282eae38
commit 9562a7d0bb
5 changed files with 51 additions and 8 deletions

View File

@ -2,11 +2,12 @@
/** /**
* Class Database * Class Database
*
* Manages database connections for SQLite and MySQL (or MariaDB). * Manages database connections for SQLite and MySQL (or MariaDB).
*/ */
class Database { class Database {
/** /**
* @var PDO|null $pdo The PDO instance representing the database connection. * @var PDO|null $pdo The database connection instance.
*/ */
private $pdo; private $pdo;

View File

@ -1,13 +1,33 @@
<?php <?php
/**
* Class Host
*
* Manages the hosts in the database, providing methods to retrieve, add, edit, and delete host entries.
*/
class Host { class Host {
/**
* @var PDO|null $db The database connection instance.
*/
private $db; private $db;
/**
* Host constructor.
*
* @param Database $database The database connection object.
*/
public function __construct($database) { public function __construct($database) {
$this->db = $database->getConnection(); $this->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 = '') { public function getHostDetails($platform_id = '', $host_id = '') {
$sql = 'SELECT $sql = 'SELECT
id, 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) { public function addHost($newHost) {
try { try {
$sql = 'INSERT INTO hosts $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) { public function editHost($platform_id, $updatedHost) {
try { try {
$sql = 'UPDATE hosts SET $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) { public function deleteHost($host_id) {
try { try {
$sql = 'DELETE FROM hosts $sql = 'DELETE FROM hosts

View File

@ -2,11 +2,12 @@
/** /**
* Class Log * Class Log
*
* Handles logging events into a database and reading log entries. * Handles logging events into a database and reading log entries.
*/ */
class Log { class Log {
/** /**
* @var PDO $db The database connection instance. * @var PDO|null $db The database connection instance.
*/ */
private $db; private $db;

View File

@ -2,11 +2,12 @@
/** /**
* Class Server * Class Server
*
* Handles server-related operations, including retrieving server status. * Handles server-related operations, including retrieving server status.
*/ */
class Server { class Server {
/** /**
* @var PDO|null The database connection instance. * @var PDO|null $db The database connection instance.
*/ */
private $db; private $db;

View File

@ -2,11 +2,12 @@
/** /**
* Class User * Class User
*
* Handles user-related functionalities such as registration, login, rights management, and profile updates. * Handles user-related functionalities such as registration, login, rights management, and profile updates.
*/ */
class User { class User {
/** /**
* @var PDO Database connection instance. * @var PDO|null $db The database connection instance.
*/ */
private $db; private $db;