<?php

namespace Application\Service\Extension\HelperV2;

use Application\Service\Extension\BaseExtension;

/**
 * @property-read FormHelper $form
 * @property-read PatientHelper $patient
 * @property-read HtmlStruct $htmlStruct
 */
class Helper extends BaseExtension
{
    private array $_mapping = [
        'form' => FormHelper::class,
        'patient' => PatientHelper::class,
        'htmlStruct' => HtmlStruct::class
    ];

    private array $_container = [];

    /**
     * @return Helper
     */
    public static function app()
    {
        return parent::app(); // TODO: Change the autogenerated stub
    }

    public function __get($name)
    {
        if (!isset($_container[$name]) && isset($this->_mapping)) {
            return $this->_container[$name] = new $this->_mapping[$name]();
        }

        throw new \Exception("Not support helper `{$name}`");
    }
}