GraphQL\Type\Definition\Config::validateMap PHP Method

validateMap() private static method

private static validateMap ( $typeName, array $map, array $definitions, null $pathStr = null )
$typeName
$map array
$definitions array
$pathStr null
    private static function validateMap($typeName, array $map, array $definitions, $pathStr = null)
    {
        $suffix = $pathStr ? " at {$pathStr}" : '';
        // Make sure there are no unexpected keys in map
        $unexpectedKeys = array_keys(array_diff_key($map, $definitions));
        if (!empty($unexpectedKeys)) {
            if (!self::$allowCustomOptions) {
                trigger_error(sprintf('"%s" type definition: Non-standard keys "%s" ' . $suffix, $typeName, implode(', ', $unexpectedKeys)));
            }
            $map = array_intersect_key($map, $definitions);
        }
        // Make sure that all required keys are present in map
        $requiredKeys = array_filter($definitions, function ($def) {
            return (self::getFlags($def) & self::REQUIRED) > 0;
        });
        $missingKeys = array_keys(array_diff_key($requiredKeys, $map));
        Utils::invariant(empty($missingKeys), "Error in '{$typeName}' type definition: Required keys missing: '%s' {$suffix}", implode(', ', $missingKeys));
        // Make sure that every map value is valid given the definition
        foreach ($map as $key => $value) {
            self::validateEntry($typeName, $key, $value, $definitions[$key], $pathStr ? "{$pathStr}:{$key}" : $key);
        }
    }