library/Adapter/Options/OptionsMap.php
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;
    }
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;
    }
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 ; }
Option setter with validation
If option can have the specified value then it is set, otherwise this method throws exception

Tip: call it into your setter methods.

@param $key
@param $value
@return $this
@throws Exception\DomainException
@throws Exception\InvalidArgumentException
Option setter with validation If option can have the specified value then it is set otherwise this method throws exception