. */ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; use Jbtronics\SettingsBundle\Settings\Settings; use Jbtronics\SettingsBundle\Settings\SettingsParameter; use Symfony\Component\Validator\Constraints as Assert; #[Settings] class MouserSettings { #[SettingsParameter(envVar: "PROVIDER_MOUSER_KEY")] public ?string $apiKey = null; /** @var int The number of results to get from Mouser while searching (please note that this value is max 50) */ #[SettingsParameter(envVar: "int:PROVIDER_MOUSER_SEARCH_LIMIT")] #[Assert\Range(min: 1, max: 50)] public int $searchLimit = 50; /** @var MouserSearchOptions Filter search results by RoHS compliance and stock availability */ #[SettingsParameter(envVar: "PROVIDER_MOUSER_SEARCH_OPTION", envVarMapper: [self::class, "mapSearchOptionEnvVar"])] public MouserSearchOptions $searchOption = MouserSearchOptions::NONE; /** @var bool It is recommended to leave this set to 'true'. The option is not really documented by Mouser: * Used when searching for keywords in the language specified when you signed up for Search API. */ #[SettingsParameter(envVar: "bool:PROVIDER_MOUSER_SEARCH_WITH_SIGNUP_LANGUAGE")] public bool $searchWithSignUpLanguage = true; public static function mapSearchOptionEnvVar(?string $value): MouserSearchOptions { if (!$value) { return MouserSearchOptions::NONE; } return MouserSearchOptions::tryFrom($value) ?? MouserSearchOptions::NONE; } }