src/View/Helper/MenuHelper.php
public function create($name, array $options = [])
    {
        if (!is_string($name)) {
            throw new \InvalidArgumentException(sprintf(
                'The `$name` argument must be a string, `%s` given.',
                Debugger::getType($name)
            ));
        }

        if (strlen(trim($name)) === 0) {
            throw new \InvalidArgumentException('The `$name` argument must not be empty.');
        }

        $menu = $this->getMenuFactory()->createItem($name, $this->_extractMenuOptions($options));
        $this->_addMenu($menu, $this->_extractRendererOptions($options));

        return $menu;
    }
public function create($name, array $options = [])
    {
        if (!is_string($name)) {
            throw new \InvalidArgumentException(sprintf(
                'The `$name` argument must be a string, `%s` given.',
                Debugger::getType($name)
            ));
        }

        if (strlen(trim($name)) === 0) {
            throw new \InvalidArgumentException('The `$name` argument must not be empty.');
        }

        $menu = $this->getMenuFactory()->createItem($name, $this->_extractMenuOptions($options));
        $this->_addMenu($menu, $this->_extractRendererOptions($options));

        return $menu;
    }
public function create ( $ name , array $ options = [ ] ) { if ( ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The `$name` argument must be a string, `%s` given.' , Debugger :: getType ( $ name ) ) ) ; } if ( strlen ( trim ( $ name ) ) === 0 ) { throw new \ InvalidArgumentException ( 'The `$name` argument must not be empty.' ) ; } $ menu = $ this -> getMenuFactory ( ) -> createItem ( $ name , $ this -> _extractMenuOptions ( $ options ) ) ; $ this -> _addMenu ( $ menu , $ this -> _extractRendererOptions ( $ options ) ) ; return $ menu ; }
Creates a menu.

## Options

The `$options` argument supports the following keys:

- `menuAttributes`: The HTML attributes to apply to the menu element. Defaults to `null`.

Similar to the constructor, additional options that do not match the ones listed above will be
passed as options to the renderer.

@see __construct()

@throws \InvalidArgumentException In case the `$name` argument is not a string, or is empty.

@param string $name The name of the menu. The name serves as an identifier for retrieving
and rendering specific menus.
@param array $options An array of options, see the "Options" section in the method
description.
@return ItemInterface
Creates a menu .