summaryrefslogtreecommitdiffstats
path: root/vendor/gipfl/web/src/HtmlHelper.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:44:51 +0000
commita1ec78bf0dc93d0e05e5f066f1949dc3baecea06 (patch)
treeee596ce1bc9840661386f96f9b8d1f919a106317 /vendor/gipfl/web/src/HtmlHelper.php
parentInitial commit. (diff)
downloadicingaweb2-module-incubator-a1ec78bf0dc93d0e05e5f066f1949dc3baecea06.tar.xz
icingaweb2-module-incubator-a1ec78bf0dc93d0e05e5f066f1949dc3baecea06.zip
Adding upstream version 0.20.0.upstream/0.20.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gipfl/web/src/HtmlHelper.php')
-rw-r--r--vendor/gipfl/web/src/HtmlHelper.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/gipfl/web/src/HtmlHelper.php b/vendor/gipfl/web/src/HtmlHelper.php
new file mode 100644
index 0000000..19862f8
--- /dev/null
+++ b/vendor/gipfl/web/src/HtmlHelper.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace gipfl\Web;
+
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+
+abstract class HtmlHelper
+{
+ public static function elementHasClass(BaseHtmlElement $element, $class)
+ {
+ return static::classIsSet($element->getAttributes(), $class);
+ }
+
+ public static function addClassOnce(Attributes $attributes, $class)
+ {
+ if (! HtmlHelper::classIsSet($attributes, $class)) {
+ $attributes->add('class', $class);
+ }
+ }
+
+ public static function classIsSet(Attributes $attributes, $class)
+ {
+ $classes = $attributes->get('class');
+
+ return \is_array($classes) && in_array($class, $classes)
+ || \is_string($classes) && $classes === $class;
+ }
+}