Skip to content

Commit 233bbab

Browse files
Move Helper classes to php-forge/html-helper. (#338)
1 parent 995ea96 commit 233bbab

34 files changed

+148
-1121
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Change Log
22

3-
## 0.2.1 Under development
3+
## 0.3.0 Under development
4+
5+
- Enh #338: Move `Helper` classes to `php-forge/html-helper` package (@terabytesoftw)
46

57
## 0.2.0 February 27, 2024
68

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ext-mbstring": "*",
1717
"enshrined/svg-sanitize": "^0.17.0",
1818
"php-forge/awesome-widget": "^0.1.2",
19+
"php-forge/html-helper": "^0.1",
1920
"php-forge/html-interop": "^0.1",
2021
"voku/anti-xss": "^4.1"
2122
},

src/Attribute/Component/HasBrandCollection.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Component;
66

7-
use PHPForge\Html\Helper\{CssClass, Encode};
8-
use PHPForge\Widget\ElementInterface;
7+
use PHPForge\Html\{Helper\CssClass, Helper\Sanitize, Interop\RenderInterface};
98

109
/**
1110
* Is used by widgets that implement brand collection.
@@ -88,14 +87,14 @@ public function brandContainerTag(string $value): static
8887
/**
8988
* Set the brand image.
9089
*
91-
* @param ElementInterface|string $value The brand image.
90+
* @param RenderInterface|string $value The brand image.
9291
*
9392
* @return static A new instance of the current class with the specified brand image.
9493
*/
95-
public function brandImage(string|ElementInterface $value): static
94+
public function brandImage(string|RenderInterface $value): static
9695
{
9796
$new = clone $this;
98-
$new->brandImage = Encode::sanitizeXSS($value);
97+
$new->brandImage = Sanitize::html($value);
9998

10099
return $new;
101100
}
@@ -163,29 +162,29 @@ public function brandTemplate(string $value): static
163162
/**
164163
* Set the brand text.
165164
*
166-
* @param ElementInterface|string $value The brand text.
165+
* @param RenderInterface|string $value The brand text.
167166
*
168167
* @return static A new instance of the current class with the specified brand text.
169168
*/
170-
public function brandText(string|ElementInterface $value): static
169+
public function brandText(string|RenderInterface $value): static
171170
{
172171
$new = clone $this;
173-
$new->brandText = Encode::sanitizeXSS($value);
172+
$new->brandText = Sanitize::html($value);
174173

175174
return $new;
176175
}
177176

178177
/**
179178
* Set the brand toggle.
180179
*
181-
* @param ElementInterface|string $value The brand toggle.
180+
* @param RenderInterface|string $value The brand toggle.
182181
*
183182
* @return static A new instance of the current class with the specified brand toggle.
184183
*/
185-
public function brandToggle(string|ElementInterface $value): static
184+
public function brandToggle(string|RenderInterface $value): static
186185
{
187186
$new = clone $this;
188-
$new->brandToggle = Encode::sanitizeXSS($value);
187+
$new->brandToggle = Sanitize::html($value);
189188

190189
return $new;
191190
}

src/Attribute/Component/HasMenu.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Component;
66

7-
use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement menu methods.
@@ -17,14 +17,14 @@ trait HasMenu
1717
/**
1818
* Set the menu items.
1919
*
20-
* @param ElementInterface|string ...$values The menu items.
20+
* @param RenderInterface|string ...$values The menu items.
2121
*
2222
* @return static A new instance of the current class with the specified menu items.
2323
*/
24-
public function menu(string|ElementInterface ...$values): static
24+
public function menu(string|RenderInterface ...$values): static
2525
{
2626
$new = clone $this;
27-
$new->menu = Encode::sanitizeXSS(...$values);
27+
$new->menu = Sanitize::html(...$values);
2828

2929
return $new;
3030
}

src/Attribute/Component/HasToggle.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Component;
66

7-
use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement the toggle method.
@@ -16,14 +16,14 @@ trait HasToggle
1616
/**
1717
* Set the content of the toggle button.
1818
*
19-
* @param ElementInterface|string ...$values The content of the toggle button.
19+
* @param RenderInterface|string ...$values The content of the toggle button.
2020
*
2121
* @return static A new instance of the current class with the specified toggle button content.
2222
*/
23-
public function toggle(string|ElementInterface ...$values): static
23+
public function toggle(string|RenderInterface ...$values): static
2424
{
2525
$new = clone $this;
26-
$new->toggle = Encode::sanitizeXSS(...$values);
26+
$new->toggle = Sanitize::html(...$values);
2727

2828
return $new;
2929
}

src/Attribute/Component/HasToggleCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PHPForge\Html\Attribute\Component;
66

77
use InvalidArgumentException;
8-
use PHPForge\{Html\Attribute\Custom\HasValidateInList, Html\Helper\Encode, Html\Tag, Widget\ElementInterface};
8+
use PHPForge\Html\{Attribute\Custom\HasValidateInList, Helper\Sanitize, Interop\RenderInterface, Tag};
99

1010
use function array_merge;
1111

@@ -73,14 +73,14 @@ public function toggleClass(string $value): static
7373
/**
7474
* Set the `HTML` content for the toggle.
7575
*
76-
* @param ElementInterface|string ...$values The `HTML` toggle button content.
76+
* @param RenderInterface|string ...$values The `HTML` toggle button content.
7777
*
7878
* @return static A new instance of the current class with the specified toggle content.
7979
*/
80-
public function toggleContent(string|ElementInterface ...$values): static
80+
public function toggleContent(string|RenderInterface ...$values): static
8181
{
8282
$new = clone $this;
83-
$new->toggleContent = Encode::sanitizeXSS(...$values);
83+
$new->toggleContent = Sanitize::html(...$values);
8484

8585
return $new;
8686
}

src/Attribute/Custom/HasContainerPrefix.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Custom;
66

7-
use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement container prefix method.
@@ -16,14 +16,14 @@ trait HasContainerPrefix
1616
/**
1717
* Set the `HTML` container prefix content.
1818
*
19-
* @param ElementInterface|string ...$values The `HTML` container prefix content.
19+
* @param RenderInterface|string ...$values The `HTML` container prefix content.
2020
*
2121
* @return static A new instance of the current class with the specified container prefix content.
2222
*/
23-
public function containerPrefix(string|ElementInterface ...$values): static
23+
public function containerPrefix(string|RenderInterface ...$values): static
2424
{
2525
$new = clone $this;
26-
$new->containerPrefix = Encode::sanitizeXSS(...$values);
26+
$new->containerPrefix = Sanitize::html(...$values);
2727

2828
return $new;
2929
}

src/Attribute/Custom/HasContainerSuffix.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Custom;
66

7-
use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement container suffix method.
@@ -16,14 +16,14 @@ trait HasContainerSuffix
1616
/**
1717
* Set the `HTML` container suffix content.
1818
*
19-
* @param ElementInterface|string ...$values The `HTML` container suffix content.
19+
* @param RenderInterface|string ...$values The `HTML` container suffix content.
2020
*
2121
* @return static A new instance of the current class with the specified container suffix content.
2222
*/
23-
public function containerSuffix(string|ElementInterface ...$values): static
23+
public function containerSuffix(string|RenderInterface ...$values): static
2424
{
2525
$new = clone $this;
26-
$new->containerSuffix = Encode::sanitizeXSS(...$values);
26+
$new->containerSuffix = Sanitize::html(...$values);
2727

2828
return $new;
2929
}

src/Attribute/Custom/HasContent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Custom;
66

7-
use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement the content method.
@@ -16,14 +16,14 @@ trait HasContent
1616
/**
1717
* Set the `HTML` content value.
1818
*
19-
* @param ElementInterface|string ...$values The `HTML` content value.
19+
* @param RenderInterface|string ...$values The `HTML` content value.
2020
*
2121
* @return static A new instance of the current class with the specified content value.
2222
*/
23-
public function content(string|ElementInterface ...$values): static
23+
public function content(string|RenderInterface ...$values): static
2424
{
2525
$new = clone $this;
26-
$new->content = Encode::sanitizeXSS(...$values);
26+
$new->content = Sanitize::html(...$values);
2727

2828
return $new;
2929
}

src/Attribute/Custom/HasLabelCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPForge\Html\Attribute\Custom;
66

7-
use PHPForge\{Html\FormControl\Label, Html\Helper\CssClass, Html\Helper\Encode, Widget\ElementInterface};
7+
use PHPForge\Html\{FormControl\Label, Helper\CssClass, Helper\Sanitize, Interop\RenderInterface};
88

99
/**
1010
* Is used by widgets that implement the label methods.
@@ -20,14 +20,14 @@ trait HasLabelCollection
2020
/**
2121
* Set the `HTML` label content.
2222
*
23-
* @param ElementInterface|string ...$values The `HTML` label content value.
23+
* @param RenderInterface|string ...$values The `HTML` label content value.
2424
*
2525
* @return static A new instance of the current class with the specified `HTML` label content.
2626
*/
27-
public function label(ElementInterface|string ...$values): static
27+
public function label(RenderInterface|string ...$values): static
2828
{
2929
$new = clone $this;
30-
$new->label = Encode::sanitizeXSS(...$values);
30+
$new->label = Sanitize::html(...$values);
3131

3232
return $new;
3333
}

0 commit comments

Comments
 (0)