public static function create(string $type): \Menu\Type\TypeInterface
    {
        if (empty($type)) {
            throw new InvalidArgumentException('Type must be a non-empty string.');
        }

        $className = __NAMESPACE__ . '\\Types\\' . Inflector::camelize($type);
        if (!class_exists($className)) {
            throw new RuntimeException('Class [' . $className . '] does not exist.');
        }

        $interface = __NAMESPACE__ . '\\' . static::INTERFACE_CLASS;
        if (!in_array($interface, class_implements($className))) {
            throw new RuntimeException('Class [' . $className . '] must implement [' . $interface . '] interface.');
        }

        return new $className();
    }
public static function create(string $type): \Menu\Type\TypeInterface
    {
        if (empty($type)) {
            throw new InvalidArgumentException('Type must be a non-empty string.');
        }

        $className = __NAMESPACE__ . '\\Types\\' . Inflector::camelize($type);
        if (!class_exists($className)) {
            throw new RuntimeException('Class [' . $className . '] does not exist.');
        }

        $interface = __NAMESPACE__ . '\\' . static::INTERFACE_CLASS;
        if (!in_array($interface, class_implements($className))) {
            throw new RuntimeException('Class [' . $className . '] must implement [' . $interface . '] interface.');
        }

        return new $className();
    }
public static function create ( string $ type ) : \ Menu \ Type \ TypeInterface { if ( empty ( $ type ) ) { throw new InvalidArgumentException ( 'Type must be a non-empty string.' ) ; } $ className = __NAMESPACE__ . '\\Types\\' . Inflector :: camelize ( $ type ) ; if ( ! class_exists ( $ className ) ) { throw new RuntimeException ( 'Class [' . $ className . '] does not exist.' ) ; } $ interface = __NAMESPACE__ . '\\' . static :: INTERFACE_CLASS ; if ( ! in_array ( $ interface , class_implements ( $ className ) ) ) { throw new RuntimeException ( 'Class [' . $ className . '] must implement [' . $ interface . '] interface.' ) ; } return new $ className ( ) ; }
Create and return menu item type object.

@param string $type Type name
@return \Menu\Type\TypeInterface
@throws \InvalidArgumentException
@throws \RuntimeException
Create and return menu item type object .