public static function widget(?array $params = null): ?string
    {
        self::$class = get_called_class();
        self::$view = App::$View;
        self::$request = App::$Request;
        self::$response = App::$Response;

        // check if class exist
        if (!class_exists(self::$class)) {
            return 'Error: Widget is not founded: ' . self::$class;
        }

        /** @var iWidget $object */
        $object = new self::$class;
        if (Any::isArray($params) && count($params) > 0) {
            foreach ($params as $property => $value) {
                if (property_exists($object, $property)) {
                    $object->{$property} = $value;
                }
            }
        }

        // initialize widget
        $object->init();
        return $object->display();
    }
public static function widget(?array $params = null): ?string
    {
        self::$class = get_called_class();
        self::$view = App::$View;
        self::$request = App::$Request;
        self::$response = App::$Response;

        // check if class exist
        if (!class_exists(self::$class)) {
            return 'Error: Widget is not founded: ' . self::$class;
        }

        /** @var iWidget $object */
        $object = new self::$class;
        if (Any::isArray($params) && count($params) > 0) {
            foreach ($params as $property => $value) {
                if (property_exists($object, $property)) {
                    $object->{$property} = $value;
                }
            }
        }

        // initialize widget
        $object->init();
        return $object->display();
    }
public static function widget ( ? array $ params = null ) : ? string { self :: $ class = get_called_class ( ) ; self :: $ view = App :: $ View ; self :: $ request = App :: $ Request ; self :: $ response = App :: $ Response ; // check if class exist if ( ! class_exists ( self :: $ class ) ) { return 'Error: Widget is not founded: ' . self :: $ class ; } /** @var iWidget $object */ $ object = new self :: $ class ; if ( Any :: isArray ( $ params ) && count ( $ params ) > 0 ) { foreach ( $ params as $ property => $ value ) { if ( property_exists ( $ object , $ property ) ) { $ object -> { $ property } = $ value ; } } } // initialize widget $ object -> init ( ) ; return $ object -> display ( ) ; }
Build and display widget
@param array|null $params
@return null|string
Build and display widget