This variant of reduce takes a \Closure which takes only a single Dependency
(as opposed to a pair of $to and $from) and applies it to both $to and $from.

@param \Closure $mappers

@return DependencyMap
505645
public function reduceEachDependency(\Closure $mappers) : DependencyMap
    {
        return $this->reduce(new self(), function (self $map, Dependency $from, Dependency $to) use ($mappers) {
            return $map->add($mappers($from), $mappers($to));
        });
    }
398735
public function mapper($entity, $entityMap = null)
    {
        if ($entity instanceof Wrapper) {
            throw new MappingException('Tried to instantiate mapper on wrapped Entity');
        }

        $entity = $this->resolveEntityClass($entity);

        $entity = $this->getInverseMorphMap($entity);

        // Return existing mapper instance if exists.
        if (array_key_exists($entity, $this->mappers)) {
            return $this->mappers[$entity];
        } else {
            return $this->buildMapper($entity, $entityMap);
        }
    }
871162
protected function transform($middleware)
    {
        if (is_string($middleware))
        {
            return $this->container->get($middleware);
        }

        if (is_callable($middleware))
        {
            return new ClosureMiddleware($middleware);
        }

        return $middleware;
    }
5705
protected function mapper($alias = false)
    {
        return Manager::getInstance()->getMapper($alias ? $alias : $this->sMapperAlias);
    }
235350
public function exposed(): MapInterface
    {
        return $this->exposed->reduce(
            new Map(Name::class, Constructor::class),
            static function(Map $exposed, string $name, Service $service): Map {
                return $exposed->put(
                    $service->exposedAs(),
                    $service->constructor()
                );
            }
        );
    }
1024885
public function parameters(): MapInterface
    {
        if ($this->parameters) {
            return $this->parameters;
        }

        return $this->parameters = $this->elements->reduce(
            new Map('string', Parameter::class),
            function(Map $carry, $element): Map {
                return $carry->merge($element->parameters());
            }
        );
    }
754984
public function reduce($closure, $initial = false)
    {
        $result = $initial;
        foreach ($this as $val) {
            $result = $closure($result, $val);
        }
        return $result;
    }
1017201
public static Map makeMap(Mapper mapper, Enumeration en) {
        return makeMap(mapper, en, false);
    }
550143
private function regenerateDependencyMap () : DependencyMap
    {
        $loader = new DependencyLoader($this->namespaceRegistry, $this->logger);

        foreach ($this->dependencyFiles as $dependencyFile)
        {
            $loader->importFile($dependencyFile);
        }

        return new DependencyMap(
            $loader->getDependencyMap()
        );
    }
478643
public function finalize($finalize)
    {
        switch ($this->query['type']) {
            case Query::TYPE_MAP_REDUCE:
                $this->query['mapReduce']['options']['finalize'] = $finalize;
                break;

            case Query::TYPE_GROUP:
                $this->query['group']['options']['finalize'] = $finalize;
                break;

            default:
                throw new BadMethodCallException('mapReduce(), map() or group() must be called before finalize()');
        }

        return $this;
    }
83026
protected function setMapper(QueryMapperInterface $mapper = null): self
    {
        if (is_null($mapper)) {
            return $this->setDefaultMapper();
        }
        
        $this->mapper = $mapper;
        
        return $this;
    }
333429
public function setChildren($children, $mapper = null)
    {
        $element = clone $this;

        $element->children = new Collection();

        return $element->addChildren($children, $mapper);
    }
420591
protected function assignPrimaryKey(array & $mappers)
    {
        $foundPrimary = false;

        foreach ($mappers as $mapper) {
            if ($foundPrimary) {
                $mapper->field->isPrimary = false;
                $mapper->field->isAutoIncrement = false;
                continue;
            }

            if ($mapper->field->isPrimary()) {
                $mapper->field->isPrimary = true;
                $foundPrimary = true;
            }
        }

        return $this;
    }
1299142
private function initializeDependencyMap (array $config, array $prefixedNamespaces, ContainerBuilder $container) : void
    {
        $registry = new NamespaceRegistry($prefixedNamespaces);
        $loader = new DependencyLoader($registry);

        foreach ($config["dependency_maps"] as $dependencyMap)
        {
            $loader->importFile($dependencyMap);
        }

        $container->getDefinition(DependencyMapFactory::class)
            ->setArgument('$dependencyFiles', $config["dependency_maps"])
            ->setArgument('$precompiledDependencyMap', $loader->getDependencyMap());
    }
338216
function reduce(callable $closure, $carry = null) {
        foreach($this->data as $val) {
            $carry = $closure($carry, $val);
        }
        
        return $carry;
    }
195740
public function map($closure)
    {
        $data = [];
        foreach ($this as $val) {
            $data[] = $closure($val);
        }
        return new Collection(compact('data'));
    }
1115757
public function addMapper(ResultMapperInterface $mapper)
    {
        if ($mapper instanceof self) {
            return $this->addMappers($mapper->mappers);
        }

        $this->mappers[] = $mapper;
    
        return $this;
    }