Skip to content

Commit

Permalink
Fix cast errors (#27)
Browse files Browse the repository at this point in the history
* Fixed cast errors with environment variables and update PHPDoc

---------

Co-authored-by: Daniel I. Kelley <[email protected]>
  • Loading branch information
aguilita1 and aguilita1 authored Nov 16, 2024
1 parent 0b4b71e commit 196e7fe
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
use SampleSyncApp\Utils;

// Load configuration from environment variables
$syncInterval = (int)($_SERVER['SA_SYNC_INTERVAL'] ?? 60);
$syncStart = $_SERVER['SA_START_SYNC'] ?? '00:00:00';
$syncEnd = $_SERVER['SA_STOP_SYNC'] ?? '23:59:59';
date_default_timezone_set($_SERVER['SA_TIME_ZONE'] ?? 'UTC');
$syncInterval = isset($_SERVER['SA_SYNC_INTERVAL'])
? (int)filter_var($_SERVER['SA_SYNC_INTERVAL'], FILTER_VALIDATE_INT) : 60;
$syncStart = isset($_SERVER['SA_START_SYNC']) && is_string($_SERVER['SA_START_SYNC'])
? (string)$_SERVER['SA_START_SYNC'] : '00:00:00';
$syncEnd = isset($_SERVER['SA_STOP_SYNC']) && is_string($_SERVER['SA_STOP_SYNC'])
? (string)$_SERVER['SA_STOP_SYNC'] : '23:59:59';
$timezone = isset($_SERVER['SA_TIME_ZONE']) && is_string($_SERVER['SA_TIME_ZONE'])
? (string)$_SERVER['SA_TIME_ZONE'] : 'UTC';
date_default_timezone_set($timezone);

// Initialize Logger
$log = initializeLogger();
Expand All @@ -34,7 +39,7 @@
$log->info(sprintf('Starting up - SampleSyncApp version: %s PROJECT_ROOT=%s', 'APP_VERSION', PROJECT_ROOT));
$log->debug('*****************START**main.php*********************');

/** @var React\EventLoop\LoopInterface $loop */
/** @var React\EventLoop\StreamSelectLoop $loop */
$loop = new StreamSelectLoop();

$loop->addPeriodicTimer($syncInterval, function () use ($log, $syncInterval, $syncStart, $syncEnd) {
Expand Down

0 comments on commit 196e7fe

Please sign in to comment.