diff --git a/wcfsetup/install/files/lib/system/form/builder/NoticeFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/NoticeFormNode.class.php index 3b00aa4b996..19fa232bf99 100644 --- a/wcfsetup/install/files/lib/system/form/builder/NoticeFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/NoticeFormNode.class.php @@ -12,33 +12,27 @@ */ class NoticeFormNode extends LanguageItemFormNode { - const AVAILABLE_TYPES = ['info', 'success', 'warning', 'error']; - - protected string $type = 'info'; + protected NoticeFormNodeType $type = NoticeFormNodeType::Info; /** * @inheritDoc */ public function getHtml() { - return '' . parent::getHtml() . ''; + return '' . parent::getHtml() . ''; } /** * Sets the type of this notice. */ - public function type(string $type): static + public function type(NoticeFormNodeType $type): static { - if (!\in_array($type, self::AVAILABLE_TYPES)) { - throw new \BadMethodCallException("Invalid value '{$type}' given."); - } - $this->type = $type; return $this; } - public function getType(): string + public function getType(): NoticeFormNodeType { return $this->type; } diff --git a/wcfsetup/install/files/lib/system/form/builder/NoticeFormNodeType.class.php b/wcfsetup/install/files/lib/system/form/builder/NoticeFormNodeType.class.php new file mode 100644 index 00000000000..77133ee7cf9 --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/NoticeFormNodeType.class.php @@ -0,0 +1,29 @@ + + * @since 6.1 + */ +enum NoticeFormNodeType +{ + case Info; + case Success; + case Warning; + case Error; + + public function toString(): string + { + return match ($this) { + self::Info => 'info', + self::Success => 'success', + self::Warning => 'warning', + self::Error => 'error', + }; + } +}