dpl/app/Services/MailFlow/Settings.php

33 lines
1000 B
PHP

<?php
namespace App\Services\MailFlow;
class Settings
{
public static function all(): array
{
$settings = array_replace(config('mailflow', []), (array) admin_setting('mail_flow', []));
foreach (['resend_key', 'resend_webhook_secret', 'imap_password'] as $key) {
if (str_starts_with((string) ($settings[$key] ?? ''), 'encrypted:')) {
$settings[$key] = \Illuminate\Support\Facades\Crypt::decryptString(substr($settings[$key], 10));
}
}
return $settings;
}
public static function get(string $key, mixed $default = null): mixed
{
return self::all()[$key] ?? $default;
}
public static function publicSettings(): array
{
$settings = self::all();
foreach (['resend_key', 'resend_webhook_secret', 'imap_password'] as $key) {
$settings[$key . '_configured'] = !empty($settings[$key]);
unset($settings[$key]);
}
return $settings;
}
}