src/Common/Internal/ServiceSettings.php
protected static function getValidator($requirements, $isRequired, $atLeastOne)
    {
        // @codingStandardsIgnoreStart

        return function ($userSettings) use ($requirements, $isRequired, $atLeastOne) {
            $oneFound = false;
            $result = array_change_key_case($userSettings);
            foreach ($requirements as $requirement) {
                $settingName = strtolower($requirement[Resources::SETTING_NAME]);

                // Check if the setting name exists in the provided user settings.
                if (array_key_exists($settingName, $result)) {
                    // Check if the provided user setting value is valid.
                    $validationFunc = $requirement[Resources::SETTING_CONSTRAINT];
                    $isValid = $validationFunc($result[$settingName]);

                    if ($isValid) {
                        // Remove the setting as indicator for successful validation.
                        unset($result[$settingName]);
                        $oneFound = true;
                    }
                } else {
                    // If required then fail because the setting does not exist
                    if ($isRequired) {
                        return null;
                    }
                }
            }

            if ($atLeastOne) {
                // At least one requirement must succeed, otherwise fail.
                return $oneFound ? $result : null;
            } else {
                return $result;
            }
        };

        // @codingStandardsIgnoreEnd
    }
protected static function getValidator($requirements, $isRequired, $atLeastOne)
    {
        // @codingStandardsIgnoreStart

        return function ($userSettings) use ($requirements, $isRequired, $atLeastOne) {
            $oneFound = false;
            $result = array_change_key_case($userSettings);
            foreach ($requirements as $requirement) {
                $settingName = strtolower($requirement[Resources::SETTING_NAME]);

                // Check if the setting name exists in the provided user settings.
                if (array_key_exists($settingName, $result)) {
                    // Check if the provided user setting value is valid.
                    $validationFunc = $requirement[Resources::SETTING_CONSTRAINT];
                    $isValid = $validationFunc($result[$settingName]);

                    if ($isValid) {
                        // Remove the setting as indicator for successful validation.
                        unset($result[$settingName]);
                        $oneFound = true;
                    }
                } else {
                    // If required then fail because the setting does not exist
                    if ($isRequired) {
                        return null;
                    }
                }
            }

            if ($atLeastOne) {
                // At least one requirement must succeed, otherwise fail.
                return $oneFound ? $result : null;
            } else {
                return $result;
            }
        };

        // @codingStandardsIgnoreEnd
    }
protected static function getValidator ( $ requirements , $ isRequired , $ atLeastOne ) { // @codingStandardsIgnoreStart return function ( $ userSettings ) use ( $ requirements , $ isRequired , $ atLeastOne ) { $ oneFound = false ; $ result = array_change_key_case ( $ userSettings ) ; foreach ( $ requirements as $ requirement ) { $ settingName = strtolower ( $ requirement [ Resources :: SETTING_NAME ] ) ; // Check if the setting name exists in the provided user settings. if ( array_key_exists ( $ settingName , $ result ) ) { // Check if the provided user setting value is valid. $ validationFunc = $ requirement [ Resources :: SETTING_CONSTRAINT ] ; $ isValid = $ validationFunc ( $ result [ $ settingName ] ) ; if ( $ isValid ) { // Remove the setting as indicator for successful validation. unset ( $ result [ $ settingName ] ) ; $ oneFound = true ; } } else { // If required then fail because the setting does not exist if ( $ isRequired ) { return null ; } } } if ( $ atLeastOne ) { // At least one requirement must succeed, otherwise fail. return $ oneFound ? $ result : null ; } else { return $ result ; } } ; // @codingStandardsIgnoreEnd }
Creates an anonymous function that acts as predicate.

@param array $requirements The array of conditions to satisfy
@param bool  $isRequired   Either these conditions are all required or all
optional
@param bool  $atLeastOne   Indicates that at least one requirement must
succeed

@return callable
Creates an anonymous function that acts as predicate .