From dff11f485e867f0e8fa0ce4bfaf62c43b86167a4 Mon Sep 17 00:00:00 2001 From: Krzysztof Grzelak Date: Mon, 1 Jul 2024 19:12:31 +0200 Subject: [PATCH] Add setRequired and PHPDoc update --- src/BaseItem.php | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/BaseItem.php b/src/BaseItem.php index 8963cd0..24f7c9e 100644 --- a/src/BaseItem.php +++ b/src/BaseItem.php @@ -31,7 +31,7 @@ public function __construct() } /** - * @description Set the id attribute of the input + * @description Set the id attribute of the element * @param string|int $id * @return static */ @@ -55,8 +55,8 @@ public function setId(string $id): static } /** - * @description Set the name attribute of the input - * @param string $name - Name of the input + * @description Set the name attribute of the element + * @param string $name - Name of the element * @return static */ public function name(string $name): static @@ -68,7 +68,7 @@ public function name(string $name): static /** * @deprecated Use name() instead - * @param string $name - Name of the input + * @param string $name - Name of the element * @return $this */ public function setName(string $name): static @@ -105,7 +105,7 @@ public function setType(?string $type = null): static /** * @description Set the value of the input - * @param mixed|null $value - Value of the input + * @param mixed|null $value - Value of the element * @return static */ public function value(mixed $value = null): static @@ -144,7 +144,7 @@ public function setValue(mixed $value = null): static } /** - * @description Set the placeholder of the input + * @description Set the placeholder of the element * @param string $placeholder * @return static */ @@ -156,7 +156,7 @@ public function placeholder(string $placeholder): static } /** - * @description Set the required attribute of the input + * @description Set the required attribute of the element * @param bool $required * @return static */ @@ -168,8 +168,20 @@ public function required(bool $required): static } /** - * @description Set the class of the input - * @param string $class - Name of the class + * @deprecated Use required() instead + * @param bool $required + * @return static + */ + public function setRequired(bool $required): static + { + $this->attributes->setAttribute('required', $required); + + return $this; + } + + /** + * @description Set the class of the element + * @param string $class - Name of the element class * @return static */ public function setClass(string $class): static @@ -180,8 +192,8 @@ public function setClass(string $class): static } /** - * @description Add a class to the input - * @param string $class - Name of the class + * @description Add a class to the element + * @param string $class - Name of the element class * @return static */ public function addClass(string $class): static @@ -192,7 +204,7 @@ public function addClass(string $class): static } /** - * @description Set the attribute of the input + * @description Set the attribute of the element * @param string|int $name - Name of the attribute * @param string|null $value - Value of the attribute * @return static