Added a more strict way to handle valid and expected env vars

This commit is contained in:
Alejandro Celaya
2022-01-20 20:16:37 +01:00
parent 07d24f70e1
commit 747dac531d
16 changed files with 228 additions and 69 deletions

View File

@@ -2,16 +2,17 @@
declare(strict_types=1);
use function Shlinkio\Shlink\Config\env;
use Shlinkio\Shlink\Core\Config\EnvVars;
return (static function (): array {
$webhooks = env('VISITS_WEBHOOKS');
$webhooks = EnvVars::VISITS_WEBHOOKS()->loadFromEnv();
return [
'visits_webhooks' => [
'webhooks' => $webhooks === null ? [] : explode(',', $webhooks),
'notify_orphan_visits_to_webhooks' => (bool) env('NOTIFY_ORPHAN_VISITS_TO_WEBHOOKS', false),
'notify_orphan_visits_to_webhooks' =>
(bool) EnvVars::NOTIFY_ORPHAN_VISITS_TO_WEBHOOKS()->loadFromEnv(false),
],
];