<?php

namespace GriffinForms\Admin\Html\Elements;

class PageHeading extends \GriffinForms\Admin\Html\Format
{
    protected $text;
    protected $subtext;
    
    public function html()
    {
        $subtext = trim((string) $this->subtext);

        echo '<div class="griffinforms-itempage-heading row"><div class="col">';
        echo '<h3>';
        echo esc_html($this->text);
        if ($subtext !== '') {
            echo ' <span class="badge text-bg-secondary">' . esc_html($subtext) . '</span>';
        }
        echo '</h3>';
        echo '</div></div>';
        
    }
    
    public function __construct($text = 'missing heading text', $subtext = '')
    {
        $this->text = $text;
        $this->subtext = $subtext;
    }
}
