Core/Html/AbstractHtml.php
public function build(): string
    {
        $html_attr = [];

        if (!$this->element) {
            $this->element = strtolower((new \ReflectionClass($this))->getShortName());
        }

        if (!empty($this->id)) {
            $html_attr['id'] = $this->id;
        }

        if (!empty($this->name)) {
            $html_attr['name'] = $this->name;
        }

        if ($this->css) {
            $this->css = array_unique($this->css);
            $html_attr['class'] = implode(' ', $this->css);
        }

        if ($this->style) {

            $styles = [];

            foreach ($this->style as $name => $val) {
                $styles[] = $name . ': ' . $val;
            }

            $html_attr['style'] = implode('; ', $styles);
        }

        if ($this->event) {
            foreach ($this->event as $event => $val) {
                $html_attr[$event] = $val;
            }
        }

        if ($this->data) {
            foreach ($this->data as $attr => $val) {
                $html_attr['data-' . $attr] = $val;
            }
        }

        if ($this->aria) {
            foreach ($this->aria as $attr => $val) {
                $html_attr['aria-' . $attr] = $val;
            }
        }

        if ($this->attribute) {
            foreach ($this->attribute as $attr => $val) {
                $html_attr[$attr] = $val;
            }
        }

        // we have all our attributes => build attribute string
        $tmp_attr = [];

        foreach ($html_attr as $name => $val) {
            $tmp_attr[] = $val === false ? $name : $name . (strpos($name, 'data') === false ? '="' . $val . '"' : '=\'' . $val . '\'');
        }

        $html_attr = implode(' ', $tmp_attr);

        // html attribute string has been created, lets build the element
        switch ($this->element) {

            case 'input':
            case 'meta':
            case 'img':
            case 'link':
                $html = '<' . $this->element . ($html_attr ? ' ' . $html_attr : '') . '>';
                break;

            default:
                $html = '<' . $this->element . ($html_attr ? ' ' . $html_attr : '') . '>' . $this->inner . '</' . $this->element . '>';
                break;
        }

        return $html;
    }
public function build(): string
    {
        $html_attr = [];

        if (!$this->element) {
            $this->element = strtolower((new \ReflectionClass($this))->getShortName());
        }

        if (!empty($this->id)) {
            $html_attr['id'] = $this->id;
        }

        if (!empty($this->name)) {
            $html_attr['name'] = $this->name;
        }

        if ($this->css) {
            $this->css = array_unique($this->css);
            $html_attr['class'] = implode(' ', $this->css);
        }

        if ($this->style) {

            $styles = [];

            foreach ($this->style as $name => $val) {
                $styles[] = $name . ': ' . $val;
            }

            $html_attr['style'] = implode('; ', $styles);
        }

        if ($this->event) {
            foreach ($this->event as $event => $val) {
                $html_attr[$event] = $val;
            }
        }

        if ($this->data) {
            foreach ($this->data as $attr => $val) {
                $html_attr['data-' . $attr] = $val;
            }
        }

        if ($this->aria) {
            foreach ($this->aria as $attr => $val) {
                $html_attr['aria-' . $attr] = $val;
            }
        }

        if ($this->attribute) {
            foreach ($this->attribute as $attr => $val) {
                $html_attr[$attr] = $val;
            }
        }

        // we have all our attributes => build attribute string
        $tmp_attr = [];

        foreach ($html_attr as $name => $val) {
            $tmp_attr[] = $val === false ? $name : $name . (strpos($name, 'data') === false ? '="' . $val . '"' : '=\'' . $val . '\'');
        }

        $html_attr = implode(' ', $tmp_attr);

        // html attribute string has been created, lets build the element
        switch ($this->element) {

            case 'input':
            case 'meta':
            case 'img':
            case 'link':
                $html = '<' . $this->element . ($html_attr ? ' ' . $html_attr : '') . '>';
                break;

            default:
                $html = '<' . $this->element . ($html_attr ? ' ' . $html_attr : '') . '>' . $this->inner . '</' . $this->element . '>';
                break;
        }

        return $html;
    }
public function build ( ) : string { $ html_attr = [ ] ; if ( ! $ this -> element ) { $ this -> element = strtolower ( ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ) ; } if ( ! empty ( $ this -> id ) ) { $ html_attr [ 'id' ] = $ this -> id ; } if ( ! empty ( $ this -> name ) ) { $ html_attr [ 'name' ] = $ this -> name ; } if ( $ this -> css ) { $ this -> css = array_unique ( $ this -> css ) ; $ html_attr [ 'class' ] = implode ( ' ' , $ this -> css ) ; } if ( $ this -> style ) { $ styles = [ ] ; foreach ( $ this -> style as $ name => $ val ) { $ styles [ ] = $ name . ': ' . $ val ; } $ html_attr [ 'style' ] = implode ( '; ' , $ styles ) ; } if ( $ this -> event ) { foreach ( $ this -> event as $ event => $ val ) { $ html_attr [ $ event ] = $ val ; } } if ( $ this -> data ) { foreach ( $ this -> data as $ attr => $ val ) { $ html_attr [ 'data-' . $ attr ] = $ val ; } } if ( $ this -> aria ) { foreach ( $ this -> aria as $ attr => $ val ) { $ html_attr [ 'aria-' . $ attr ] = $ val ; } } if ( $ this -> attribute ) { foreach ( $ this -> attribute as $ attr => $ val ) { $ html_attr [ $ attr ] = $ val ; } } // we have all our attributes => build attribute string $ tmp_attr = [ ] ; foreach ( $ html_attr as $ name => $ val ) { $ tmp_attr [ ] = $ val === false ? $ name : $ name . ( strpos ( $ name , 'data' ) === false ? '="' . $ val . '"' : '=\'' . $ val . '\'' ) ; } $ html_attr = implode ( ' ' , $ tmp_attr ) ; // html attribute string has been created, lets build the element switch ( $ this -> element ) { case 'input' : case 'meta' : case 'img' : case 'link' : $ html = '<' . $ this -> element . ( $ html_attr ? ' ' . $ html_attr : '' ) . '>' ; break ; default : $ html = '<' . $ this -> element . ( $ html_attr ? ' ' . $ html_attr : '' ) . '>' . $ this -> inner . '</' . $ this -> element . '>' ; break ; } return $ html ; }
Builds and returns the html code created out of all set attributes and their values

@return string
Builds and returns the html code created out of all set attributes and their values