30 lines
586 B
PHP
30 lines
586 B
PHP
|
<?php
|
||
|
|
||
|
namespace kernel\helpers;
|
||
|
|
||
|
class Html
|
||
|
{
|
||
|
|
||
|
public static function img(string $src, array $params = [])
|
||
|
{
|
||
|
$paramsStr = self::createParams($params);
|
||
|
return "<img src='$src' $paramsStr>";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @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;
|
||
|
}
|
||
|
|
||
|
}
|