Skip to content

Commit

Permalink
Move Helper classes to php-forge/html-helper. (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 28, 2024
1 parent 995ea96 commit 233bbab
Show file tree
Hide file tree
Showing 34 changed files with 148 additions and 1,121 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## 0.2.1 Under development
## 0.3.0 Under development

- Enh #338: Move `Helper` classes to `php-forge/html-helper` package (@terabytesoftw)

## 0.2.0 February 27, 2024

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ext-mbstring": "*",
"enshrined/svg-sanitize": "^0.17.0",
"php-forge/awesome-widget": "^0.1.2",
"php-forge/html-helper": "^0.1",
"php-forge/html-interop": "^0.1",
"voku/anti-xss": "^4.1"
},
Expand Down
21 changes: 10 additions & 11 deletions src/Attribute/Component/HasBrandCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace PHPForge\Html\Attribute\Component;

use PHPForge\Html\Helper\{CssClass, Encode};
use PHPForge\Widget\ElementInterface;
use PHPForge\Html\{Helper\CssClass, Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement brand collection.
Expand Down Expand Up @@ -88,14 +87,14 @@ public function brandContainerTag(string $value): static
/**
* Set the brand image.
*
* @param ElementInterface|string $value The brand image.
* @param RenderInterface|string $value The brand image.
*
* @return static A new instance of the current class with the specified brand image.
*/
public function brandImage(string|ElementInterface $value): static
public function brandImage(string|RenderInterface $value): static
{
$new = clone $this;
$new->brandImage = Encode::sanitizeXSS($value);
$new->brandImage = Sanitize::html($value);

return $new;
}
Expand Down Expand Up @@ -163,29 +162,29 @@ public function brandTemplate(string $value): static
/**
* Set the brand text.
*
* @param ElementInterface|string $value The brand text.
* @param RenderInterface|string $value The brand text.
*
* @return static A new instance of the current class with the specified brand text.
*/
public function brandText(string|ElementInterface $value): static
public function brandText(string|RenderInterface $value): static
{
$new = clone $this;
$new->brandText = Encode::sanitizeXSS($value);
$new->brandText = Sanitize::html($value);

return $new;
}

/**
* Set the brand toggle.
*
* @param ElementInterface|string $value The brand toggle.
* @param RenderInterface|string $value The brand toggle.
*
* @return static A new instance of the current class with the specified brand toggle.
*/
public function brandToggle(string|ElementInterface $value): static
public function brandToggle(string|RenderInterface $value): static
{
$new = clone $this;
$new->brandToggle = Encode::sanitizeXSS($value);
$new->brandToggle = Sanitize::html($value);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Component/HasMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Component;

use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement menu methods.
Expand All @@ -17,14 +17,14 @@ trait HasMenu
/**
* Set the menu items.
*
* @param ElementInterface|string ...$values The menu items.
* @param RenderInterface|string ...$values The menu items.
*
* @return static A new instance of the current class with the specified menu items.
*/
public function menu(string|ElementInterface ...$values): static
public function menu(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->menu = Encode::sanitizeXSS(...$values);
$new->menu = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Component/HasToggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Component;

use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement the toggle method.
Expand All @@ -16,14 +16,14 @@ trait HasToggle
/**
* Set the content of the toggle button.
*
* @param ElementInterface|string ...$values The content of the toggle button.
* @param RenderInterface|string ...$values The content of the toggle button.
*
* @return static A new instance of the current class with the specified toggle button content.
*/
public function toggle(string|ElementInterface ...$values): static
public function toggle(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->toggle = Encode::sanitizeXSS(...$values);
$new->toggle = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Component/HasToggleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PHPForge\Html\Attribute\Component;

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

use function array_merge;

Expand Down Expand Up @@ -73,14 +73,14 @@ public function toggleClass(string $value): static
/**
* Set the `HTML` content for the toggle.
*
* @param ElementInterface|string ...$values The `HTML` toggle button content.
* @param RenderInterface|string ...$values The `HTML` toggle button content.
*
* @return static A new instance of the current class with the specified toggle content.
*/
public function toggleContent(string|ElementInterface ...$values): static
public function toggleContent(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->toggleContent = Encode::sanitizeXSS(...$values);
$new->toggleContent = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasContainerPrefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement container prefix method.
Expand All @@ -16,14 +16,14 @@ trait HasContainerPrefix
/**
* Set the `HTML` container prefix content.
*
* @param ElementInterface|string ...$values The `HTML` container prefix content.
* @param RenderInterface|string ...$values The `HTML` container prefix content.
*
* @return static A new instance of the current class with the specified container prefix content.
*/
public function containerPrefix(string|ElementInterface ...$values): static
public function containerPrefix(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->containerPrefix = Encode::sanitizeXSS(...$values);
$new->containerPrefix = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasContainerSuffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement container suffix method.
Expand All @@ -16,14 +16,14 @@ trait HasContainerSuffix
/**
* Set the `HTML` container suffix content.
*
* @param ElementInterface|string ...$values The `HTML` container suffix content.
* @param RenderInterface|string ...$values The `HTML` container suffix content.
*
* @return static A new instance of the current class with the specified container suffix content.
*/
public function containerSuffix(string|ElementInterface ...$values): static
public function containerSuffix(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->containerSuffix = Encode::sanitizeXSS(...$values);
$new->containerSuffix = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\{Html\Helper\Encode, Widget\ElementInterface};
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement the content method.
Expand All @@ -16,14 +16,14 @@ trait HasContent
/**
* Set the `HTML` content value.
*
* @param ElementInterface|string ...$values The `HTML` content value.
* @param RenderInterface|string ...$values The `HTML` content value.
*
* @return static A new instance of the current class with the specified content value.
*/
public function content(string|ElementInterface ...$values): static
public function content(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->content = Encode::sanitizeXSS(...$values);
$new->content = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasLabelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

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

/**
* Is used by widgets that implement the label methods.
Expand All @@ -20,14 +20,14 @@ trait HasLabelCollection
/**
* Set the `HTML` label content.
*
* @param ElementInterface|string ...$values The `HTML` label content value.
* @param RenderInterface|string ...$values The `HTML` label content value.
*
* @return static A new instance of the current class with the specified `HTML` label content.
*/
public function label(ElementInterface|string ...$values): static
public function label(RenderInterface|string ...$values): static
{
$new = clone $this;
$new->label = Encode::sanitizeXSS(...$values);
$new->label = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasPrefixCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PHPForge\Html\Attribute\Custom;

use InvalidArgumentException;
use PHPForge\{Html\Helper\CssClass, Html\Helper\Encode, Html\Tag, Widget\ElementInterface};
use PHPForge\Html\{Helper\CssClass, Helper\Sanitize, Interop\RenderInterface, Tag};

/**
* Is used by widgets that implement the prefix collection.
Expand All @@ -20,14 +20,14 @@ trait HasPrefixCollection
/**
* Set the `HTML` prefix content.
*
* @param ElementInterface|string ...$values The `HTML` prefix content.
* @param RenderInterface|string ...$values The `HTML` prefix content.
*
* @return static A new instance of the current class with the specified prefix content.
*/
public function prefix(string|ElementInterface ...$values): static
public function prefix(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->prefix = Encode::sanitizeXSS(...$values);
$new->prefix = Sanitize::html(...$values);

return $new;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Attribute/Custom/HasPrefixItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\Html\Helper\Encode;
use PHPForge\Widget\ElementInterface;
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement the prefix item methods.
Expand All @@ -17,14 +16,14 @@ trait HasPrefixItems
/**
* Set the `HTML` prefix items content.
*
* @param ElementInterface|string ...$values The `HTML` prefix item content.
* @param RenderInterface|string ...$values The `HTML` prefix item content.
*
* @return static A new instance of the current class with the specified prefix item content.
*/
public function prefixItems(string|ElementInterface ...$values): static
public function prefixItems(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->prefixItems = Encode::sanitizeXSS(...$values);
$new->prefixItems = Sanitize::html(...$values);

return $new;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Attribute/Custom/HasSuffixCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PHPForge\Html\Attribute\Custom;

use InvalidArgumentException;
use PHPForge\{Html\Helper\CssClass, Html\Helper\Encode, Html\Tag, Widget\ElementInterface};
use PHPForge\Html\{Helper\CssClass, Helper\Sanitize, Interop\RenderInterface, Tag};

/**
* Is used by widgets that implement the prefix and suffix methods.
Expand All @@ -20,14 +20,14 @@ trait HasSuffixCollection
/**
* Set the `HTML` suffix content.
*
* @param ElementInterface|string ...$values The `HTML` suffix content.
* @param RenderInterface|string ...$values The `HTML` suffix content.
*
* @return static A new instance of the current class with the specified suffix content.
*/
public function suffix(string|ElementInterface ...$values): static
public function suffix(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->suffix = Encode::sanitizeXSS(...$values);
$new->suffix = Sanitize::html(...$values);

return $new;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Attribute/Custom/HasSuffixItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\Html\Helper\Encode;
use PHPForge\Widget\ElementInterface;
use PHPForge\Html\{Helper\Sanitize, Interop\RenderInterface};

/**
* Is used by widgets that implement the suffix item methods.
Expand All @@ -17,14 +16,14 @@ trait HasSuffixItems
/**
* Set the `HTML` suffix items content.
*
* @param ElementInterface|string ...$values The `HTML` suffix item content.
* @param RenderInterface|string ...$values The `HTML` suffix item content.
*
* @return static A new instance of the current class with the specified suffix item content.
*/
public function suffixItems(string|ElementInterface ...$values): static
public function suffixItems(string|RenderInterface ...$values): static
{
$new = clone $this;
$new->suffixItems = Encode::sanitizeXSS(...$values);
$new->suffixItems = Sanitize::html(...$values);

return $new;
}
Expand Down

0 comments on commit 233bbab

Please sign in to comment.