49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Preferences;
|
|
|
|
class PreferencesOptionsService
|
|
{
|
|
public function defaultPreferences(): array
|
|
{
|
|
return [
|
|
'receive_email_notifications' => true,
|
|
'receive_sms_notifications' => true,
|
|
'theme' => 'light',
|
|
'language' => 'en',
|
|
'style_color' => 'blue',
|
|
'menu_color' => 'white',
|
|
];
|
|
}
|
|
|
|
public function styleOptions(): array
|
|
{
|
|
return ['blue', 'green', 'red', 'orange', 'gray', 'black', 'white'];
|
|
}
|
|
|
|
public function menuOptions(): array
|
|
{
|
|
return ['white', 'gray', 'black', 'blue', 'green'];
|
|
}
|
|
|
|
public function normalizeStyle(?string $style): ?string
|
|
{
|
|
if (!$style) {
|
|
return null;
|
|
}
|
|
|
|
$style = trim($style);
|
|
return in_array($style, $this->styleOptions(), true) ? $style : null;
|
|
}
|
|
|
|
public function normalizeMenu(?string $menu): ?string
|
|
{
|
|
if (!$menu) {
|
|
return null;
|
|
}
|
|
|
|
$menu = trim($menu);
|
|
return in_array($menu, $this->menuOptions(), true) ? $menu : null;
|
|
}
|
|
}
|