protected static function setting($name)
    {
        $validValues = func_get_args();

        // Remove $name argument.
        unset($validValues[0]);

        $validValuesCount = func_num_args();

        $predicate = function ($settingValue) use ($validValuesCount, $validValues) {
            if (empty($validValues)) {
                // No restrictions, succeed,
                return true;
            }

            // Check to find if the $settingValue is valid or not. The index must
            // start from 1 as unset deletes the value but does not update the array
            // indecies.
            for ($index = 1; $index < $validValuesCount; $index++) {
                if ($settingValue == $validValues[$index]) {
                    // $settingValue is found in valid values set, succeed.
                    return true;
                }
            }

            throw new \RuntimeException(
                sprintf(
                    Resources::INVALID_CONFIG_VALUE,
                    $settingValue,
                    implode("\n", $validValues)
                )
            );

            // $settingValue is missing in valid values set, fail.
            return false;
        };

        return self::settingWithFunc($name, $predicate);
    }
protected static function setting($name)
    {
        $validValues = func_get_args();

        // Remove $name argument.
        unset($validValues[0]);

        $validValuesCount = func_num_args();

        $predicate = function ($settingValue) use ($validValuesCount, $validValues) {
            if (empty($validValues)) {
                // No restrictions, succeed,
                return true;
            }

            // Check to find if the $settingValue is valid or not. The index must
            // start from 1 as unset deletes the value but does not update the array
            // indecies.
            for ($index = 1; $index < $validValuesCount; $index++) {
                if ($settingValue == $validValues[$index]) {
                    // $settingValue is found in valid values set, succeed.
                    return true;
                }
            }

            throw new \RuntimeException(
                sprintf(
                    Resources::INVALID_CONFIG_VALUE,
                    $settingValue,
                    implode("\n", $validValues)
                )
            );

            // $settingValue is missing in valid values set, fail.
            return false;
        };

        return self::settingWithFunc($name, $predicate);
    }
protected static function setting ( $ name ) { $ validValues = func_get_args ( ) ; // Remove $name argument. unset ( $ validValues [ 0 ] ) ; $ validValuesCount = func_num_args ( ) ; $ predicate = function ( $ settingValue ) use ( $ validValuesCount , $ validValues ) { if ( empty ( $ validValues ) ) { // No restrictions, succeed, return true ; } // Check to find if the $settingValue is valid or not. The index must // start from 1 as unset deletes the value but does not update the array // indecies. for ( $ index = 1 ; $ index < $ validValuesCount ; $ index ++ ) { if ( $ settingValue == $ validValues [ $ index ] ) { // $settingValue is found in valid values set, succeed. return true ; } } throw new \ RuntimeException ( sprintf ( Resources :: INVALID_CONFIG_VALUE , $ settingValue , implode ( "\n" , $ validValues ) ) ) ; // $settingValue is missing in valid values set, fail. return false ; } ; return self :: settingWithFunc ( $ name , $ predicate ) ; }
Creates a setting value condition that validates it is one of the
passed valid values.

@param string $name The setting key name.

@return array
Creates a setting value condition that validates it is one of the passed valid values .