ProcessSetting::Payments, 'contract_documents' => ProcessSetting::Documents, 'guest_messages' => ProcessSetting::GuestMessages, ]; public const LABELS = [ 'contract' => 'Vertragsabschluss', 'collection' => 'Inkasso (Geld des Gastes)', 'contract_documents' => 'Vertragsdokumentation', 'supplementary_documents' => 'Ergänzende Gastunterlagen', 'guest_messages' => 'Gastkommunikation und Anreiseinformation', 'local_services' => 'Lokale Leistungen', ]; /** * @param array $fixed * @param array> $variable */ private function __construct(public readonly array $fixed, public readonly array $variable) {} /** * @param array $fixed * @param array> $variable */ public static function of(array $fixed, array $variable = []): self { return new self($fixed, $variable); } public function isFixed(string $field): bool { return array_key_exists($field, $this->fixed); } /** * The values the configurator may offer for a field (one value when the model fixes it). * * @return list */ public function allowed(string $field): array { return $this->isFixed($field) ? [$this->fixed[$field]] : ($this->variable[$field] ?? []); } /** * Whether a setting value fits the model (used by the configurator and by the plausibility check of a plan). */ public function admits(ProcessSetting $setting, Responsibility $value): bool { $field = array_search($setting, self::SETTINGS, true); return $field === false || $this->allowed($field) === [] || in_array($value, $this->allowed($field), true); } }