protected function setElementClass(ElementInterface $element)
    {
        $class = $element->getAttribute('class');
        $type  = $element->getOption('type') ? : self::TYPE_DEFAULT;

        if (!in_array($type, self::TYPES, true)) {
            throw new Exception\DomainException(sprintf(
                '%s requires that the button type is one of "' . implode('", "', self::TYPES) . '"',
                __METHOD__
            ));
        }

        if ($class) {
            $class .= ' ';
        }
        $class .= 'btn btn-' . $type;
        $element->setAttribute('class', $class);
    }