... // // // class UI_Alert implements UITagInterface { /** * @param string $tagName = 'p5:Alert' * @param array $props * @param array $childrens * * @return string html code */ static function h($tagName, $props = [], $childrens = []) { $type = self::convertType($props['type']); return UI::h('div', [ 'class' => "alert alert-{$type}" ], $childrens); } static function convertType($type) { switch (strtolower($type)) { case 'success': return 'success'; case 'info': return 'info'; case 'warning': return 'warning'; case 'danger': return 'danger'; case 'error': return 'danger'; default: return 'info'; } } }