2024-11-29 14:07:55 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace kernel\helpers;
|
|
|
|
|
|
|
|
class Html
|
|
|
|
{
|
|
|
|
|
|
|
|
public static function img(string $src, array $params = [])
|
|
|
|
{
|
|
|
|
$paramsStr = self::createParams($params);
|
|
|
|
return "<img src='$src' $paramsStr>";
|
|
|
|
}
|
|
|
|
|
2024-12-04 15:36:11 +03:00
|
|
|
public static function h(string|int $type = 1, string $title = '', array $params = [])
|
|
|
|
{
|
|
|
|
$paramsStr = self::createParams($params);
|
|
|
|
return "<h$type $paramsStr>$title</h$type>";
|
|
|
|
}
|
|
|
|
|
2024-11-29 14:07:55 +03:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function createParams(array $data = []): string
|
|
|
|
{
|
|
|
|
$paramsString = "";
|
|
|
|
foreach($data as $key => $param){
|
|
|
|
if(is_string($param)){
|
|
|
|
$paramsString .= $key . "='" . $param . "'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $paramsString;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|