diff --git a/MicrofyClass.php b/MicrofyClass.php
index c1d4e8c..6415299 100644
--- a/MicrofyClass.php
+++ b/MicrofyClass.php
@@ -326,42 +326,44 @@ public static function a(string $href, ?string $text = null, string $target = ''
return "$text";
}
- public static function htmlTable(array $array, string $class = '', string $id = ''): string
-{
- if (empty($array)) return "
No data.
";
-
- $idAttr = $id !== '' ? " id='" . htmlspecialchars($id, ENT_QUOTES) . "'" : '';
-
- if ($class !== '') {
- $tableTag = "";
- } else {
- $tableTag = "";
- }
-
- $html = $tableTag;
-
- // thead
- $html .= "";
- foreach (array_keys($array[0]) as $col) {
- $html .= "| " . htmlspecialchars($col, ENT_QUOTES) . " | ";
- }
- $html .= "
";
-
- // tbody
- $html .= "";
- foreach ($array as $row) {
- $html .= "";
- foreach ($row as $cell) {
- $html .= "| " . htmlspecialchars($cell, ENT_QUOTES) . " | ";
- }
- $html .= "
";
- }
- $html .= "";
-
- $html .= "
";
-
- return $html;
-}
+ public static function htmlTable(array $array, string $class = '', string $id = ''): string
+ {
+ if (empty($array)) {
+ return "No data.
";
+ }
+
+ $idAttr = $id !== '' ? " id='" . htmlspecialchars((string) $id, ENT_QUOTES) . "'" : '';
+
+ if ($class !== '') {
+ $tableTag = "";
+ } else {
+ $tableTag = "";
+ }
+
+ $html = $tableTag;
+
+ // thead
+ $html .= "";
+ foreach (array_keys($array[0]) as $col) {
+ $html .= "| " . htmlspecialchars((string) $col, ENT_QUOTES) . " | ";
+ }
+ $html .= "
";
+
+ // tbody
+ $html .= "";
+ foreach ($array as $row) {
+ $html .= "";
+ foreach ($row as $cell) {
+ $html .= "| " . htmlspecialchars((string) $cell, ENT_QUOTES) . " | ";
+ }
+ $html .= "
";
+ }
+ $html .= "";
+
+ $html .= "
";
+
+ return $html;
+ }
// --- MISC OUTPUT ---
@@ -423,15 +425,18 @@ public static function fail(string $msg = 'Error'): void
self::json(['status' => 'fail', 'msg' => $msg]);
}
- public static function jsonArray(array $data): string
-{
- return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
-}
-
-public static function jsonString(string $msg, bool $ok = true): string
-{
- return self::jsonArray(['status' => $ok ? 'ok' : 'fail', 'msg' => $msg]);
-}
+ public static function jsonArray(array $data): string
+ {
+ return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
+ }
+
+ public static function jsonString(string $msg, bool $ok = true): string
+ {
+ return self::jsonArray([
+ 'status' => $ok ? 'ok' : 'fail',
+ 'msg' => $msg,
+ ]);
+ }
// --- STRING ---
@@ -508,22 +513,25 @@ public static function span(string $text = '', string $class = ''): void
echo "$text";
}
- public static function div(string $text, array $attrs = []): string {
- $attrStr = self::buildAttr($attrs);
- return "$text
";
-}
+ public static function div(string $text, array $attrs = []): string
+ {
+ $attrStr = self::buildAttr($attrs);
+ return "$text
";
+ }
public static function section(string $text = '', string $class = ''): void
{
echo "";
}
- public static function buildAttr(array $attrs): string {
- $parts = [];
- foreach ($attrs as $k => $v) {
- $parts[] = "$k=\"" . htmlspecialchars($v) . "\"";
- }
- return $parts ? ' ' . implode(' ', $parts) : '';
-}
+ public static function buildAttr(array $attrs): string
+ {
+ $parts = [];
+ foreach ($attrs as $k => $v) {
+ $parts[] = "$k=\"" . htmlspecialchars((string) $v) . "\"";
+ }
+
+ return $parts ? ' ' . implode(' ', $parts) : '';
+ }
// --- CODE BLOCKS ---
diff --git a/microfy_aliases.php b/microfy_aliases.php
index 9a13430..016338c 100644
--- a/microfy_aliases.php
+++ b/microfy_aliases.php
@@ -412,9 +412,4 @@ function jsonString(...$args) {
return Microfy::jsonString(...$args);
}
}
-if (!function_exists('jsonString')) {
- function jsonString(...$args) {
- return Microfy::jsonString(...$args);
- }
-}