/** * @dataProvider theImplementations */ public function testThatExecutionIsDeferred(\Pinq\ITraversable $traversable, array $data) { $this->assertThatExecutionIsDeferred(function (callable $function) use($traversable) { return $traversable->join([])->on($function)->to($function); }); $this->assertThatExecutionIsDeferred(function (callable $function) use($traversable) { return $traversable->join([])->onEquality($function, $function)->to($function); }); }
/** * Evaluates the join segment values and filter upon the supplied traversable. * * @param ITraversable $traversable * @param Common\Join\Options $join * @param Queries\IResolvedParameterRegistry $resolvedParameters * * @return \Pinq\Interfaces\IJoiningToTraversable */ public static function evaluateJoinOptions(ITraversable $traversable, Common\Join\Options $join, Queries\IResolvedParameterRegistry $resolvedParameters) { $values = self::evaluateSource($join->getSource(), $resolvedParameters); $joiningTraversable = $join->isGroupJoin() ? $traversable->groupJoin($values) : $traversable->join($values); if ($join->hasFilter()) { $filter = $join->getFilter(); if ($filter instanceof Common\Join\Filter\Custom) { $joiningTraversable = $joiningTraversable->on($resolvedParameters[$filter->getOnFunction()->getCallableId()]); } elseif ($filter instanceof Common\Join\Filter\Equality) { $joiningTraversable = $joiningTraversable->onEquality($resolvedParameters[$filter->getOuterKeyFunction()->getCallableId()], $resolvedParameters[$filter->getInnerKeyFunction()->getCallableId()]); } } if ($join->hasDefault()) { $joiningTraversable = $joiningTraversable->withDefault($resolvedParameters[$join->getDefaultValueId()], $resolvedParameters[$join->getDefaultKeyId()]); } return $joiningTraversable; }