groupJoin() public method

{@inheritDoc}
public groupJoin ( $values ) : Pinq\Interfaces\IJoiningOnCollection
return Pinq\Interfaces\IJoiningOnCollection
Exemplo n.º 1
0
 /**
  * @dataProvider oneToTen
  */
 public function testGroupJoinApplyToSelfWithInnerIndexBy(\Pinq\ICollection $collection)
 {
     $inner = $collection->indexBy(function ($i) {
         return $i - 1;
     })->select(function ($i) {
         return (int) $i;
     });
     $collection->groupJoin($inner)->on(function ($outer, $inner) {
         return $outer > $inner;
     })->apply(function (&$outer, \Pinq\ITraversable $group) {
         $outer .= ':' . $group->implode(',');
     });
     $this->assertMatches($collection, [0 => '1:', 1 => '2:1', 2 => '3:1,2', 3 => '4:1,2,3', 4 => '5:1,2,3,4', 5 => '6:1,2,3,4,5', 6 => '7:1,2,3,4,5,6', 7 => '8:1,2,3,4,5,6,7', 8 => '9:1,2,3,4,5,6,7,8', 9 => '10:1,2,3,4,5,6,7,8,9']);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider oneToTen
  */
 public function testThatOnEqualityWillNotMatchNullsAndUseDefault(\Pinq\ICollection $collection, array $data)
 {
     $collection->groupJoin($collection)->onEquality(function ($i) {
         return $i % 2 === 0 ? $i : null;
     }, function ($i) {
         return $i % 2 === 0 ? $i : null;
     })->withDefault('<DEFAULT>')->apply(function (&$outer, \Pinq\ITraversable $innerGroup) {
         $outer .= ':' . $innerGroup->implode('-');
     });
     $this->assertMatches($collection, ['1:<DEFAULT>', '2:2', '3:<DEFAULT>', '4:4', '5:<DEFAULT>', '6:6', '7:<DEFAULT>', '8:8', '9:<DEFAULT>', '10:10']);
 }