public function buildDocumentFromPathsAndValues(array $paths, array $values)
    {
        $this->validateBatch($paths, FieldPath::class);

        $output = [];

        foreach ($paths as $pathIndex => $path) {
            $keys = $path->path();
            $num = count($keys);

            $val = $values[$pathIndex];
            foreach (array_reverse($keys) as $index => $key) {
                if ($num >= $index+1) {
                    $val = [
                        $key => $val
                    ];
                }
            }

            $output = $this->arrayMergeRecursive($output, $val);
        }

        return $output;
    }
public function buildDocumentFromPathsAndValues(array $paths, array $values)
    {
        $this->validateBatch($paths, FieldPath::class);

        $output = [];

        foreach ($paths as $pathIndex => $path) {
            $keys = $path->path();
            $num = count($keys);

            $val = $values[$pathIndex];
            foreach (array_reverse($keys) as $index => $key) {
                if ($num >= $index+1) {
                    $val = [
                        $key => $val
                    ];
                }
            }

            $output = $this->arrayMergeRecursive($output, $val);
        }

        return $output;
    }
public function buildDocumentFromPathsAndValues ( array $ paths , array $ values ) { $ this -> validateBatch ( $ paths , FieldPath :: class ) ; $ output = [ ] ; foreach ( $ paths as $ pathIndex => $ path ) { $ keys = $ path -> path ( ) ; $ num = count ( $ keys ) ; $ val = $ values [ $ pathIndex ] ; foreach ( array_reverse ( $ keys ) as $ index => $ key ) { if ( $ num >= $ index + 1 ) { $ val = [ $ key => $ val ] ; } } $ output = $ this -> arrayMergeRecursive ( $ output , $ val ) ; } return $ output ; }
Accepts a list of field paths and a list of values, and constructs
a nested array of fields and values.

@param FieldPath[] $paths The field paths.
@param array $values The field values.
@return array
@todo less recursion
Accepts a list of field paths and a list of values and constructs a nested array of fields and values .