PDOCountdownRepository
in package
implements
CountdownRepositoryInterface
Tags
Table of Contents
Interfaces
- CountdownRepositoryInterface
- Describes behavior of the countdown repository
Properties
- $DATE_FORMAT : string
- $dbHelper : DatabaseService
- $TABLE_NAME : string
Methods
- __construct() : mixed
- add() : int
- Persists a new countdown entity.
- delete() : bool
- Deletes a countdown by its ID.
- findAll() : array<string|int, Countdown>
- Retrieves all countdowns from storage.
- findById() : Countdown|null
- Finds a countdown by its ID.
- findCurrent() : Countdown|null
- Finds the current active countdown (with count_to in the future).
- update() : bool
- Updates an existing countdown entity.
- updateField() : bool
- Updates a specific field in a countdown.
- mapRow() : Countdown
- Maps database row to Countdown entity.
Properties
$DATE_FORMAT
private
string
$DATE_FORMAT
$dbHelper
private
DatabaseService
$dbHelper
$TABLE_NAME
private
string
$TABLE_NAME
Methods
__construct()
public
__construct(DatabaseService $dbHelper, string $TABLE_NAME, string $DATE_FORMAT) : mixed
Parameters
- $dbHelper : DatabaseService
- $TABLE_NAME : string
- $DATE_FORMAT : string
add()
Persists a new countdown entity.
public
add(Countdown $countdown) : int
Parameters
- $countdown : Countdown
-
The countdown entity to add
Tags
Return values
int —The ID of the newly inserted countdown
delete()
Deletes a countdown by its ID.
public
delete(int $id) : bool
Parameters
- $id : int
-
The countdown ID to delete
Tags
Return values
bool —True if deletion was successful, false otherwise
findAll()
Retrieves all countdowns from storage.
public
findAll() : array<string|int, Countdown>
Tags
Return values
array<string|int, Countdown> —Array of all countdown entities
findById()
Finds a countdown by its ID.
public
findById(int $id) : Countdown|null
Parameters
- $id : int
-
The countdown ID
Tags
Return values
Countdown|null —The countdown entity or null if not found
findCurrent()
Finds the current active countdown (with count_to in the future).
public
findCurrent() : Countdown|null
Tags
Return values
Countdown|null —The current countdown or null if none exists
update()
Updates an existing countdown entity.
public
update(Countdown $countdown) : bool
Parameters
- $countdown : Countdown
-
The countdown entity with updated data
Tags
Return values
bool —True if update was successful, false otherwise
updateField()
Updates a specific field in a countdown.
public
updateField(int $id, string $field, string $value) : bool
Parameters
- $id : int
-
The countdown ID
- $field : string
-
The field name to update
- $value : string
-
The new value for the field
Tags
Return values
bool —True if the update was successful, false otherwise
mapRow()
Maps database row to Countdown entity.
private
mapRow(array<string|int, mixed> $row) : Countdown
Parameters
- $row : array<string|int, mixed>