protected function setOption($key, $value)
    {
        if (!isset($this->config[$key])) {
            throw new Exception\DomainException(
                sprintf(
                    'Option "%s" does not exist; available options are (%s)',
                    $key,
                    implode(
                        ', ',
                        array_map(
                            function ($opt) {
                                return '"' . $opt . '"';
                            },
                            array_keys($this->config)
                        )
                    )
                )
            );
        }
        if (!ArrayUtils::isList($this->config[$key], false)) {
            throw new Exception\DomainException(sprintf(
                'Option "%s" does not have a list of allowed values',
                $key
            ));
        }
        if (!ArrayUtils::inArray($value, $this->config[$key], true)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Option "%s" can not be set to value "%s"; allowed values are (%s)',
                $key,
                $value,
                implode(
                    ', ',
                    array_map(
                        function ($val) {
                            return '"' . $val . '"';
                        },
                        $this->config[$key]
                    )
                )
            ));
        }
        $this->options[$key] = $value;
        return $this;
    }