(Uses strict equality '===')
public difference ( array | |
||
$values | array | |
The values to remove |
return | pinq\ITraversable |
public function visitOperation(Segments\Operation $query) { $otherValues = self::evaluateSource($query->getSource(), $this->resolvedParameters); switch ($query->getOperationType()) { case Segments\Operation::UNION: $this->traversable = $this->traversable->union($otherValues); break; case Segments\Operation::INTERSECT: $this->traversable = $this->traversable->intersect($otherValues); break; case Segments\Operation::DIFFERENCE: $this->traversable = $this->traversable->difference($otherValues); break; case Segments\Operation::APPEND: $this->traversable = $this->traversable->append($otherValues); break; case Segments\Operation::WHERE_IN: $this->traversable = $this->traversable->whereIn($otherValues); break; case Segments\Operation::EXCEPT: $this->traversable = $this->traversable->except($otherValues); break; } }
/** * @dataProvider oneToTen */ public function testThatDifferenceWithDuplicateKeysPreservesTheOriginalValues(\Pinq\ITraversable $traversable, array $data) { $otherData = [0 => 'test', 2 => 0.01, 5 => 4, 'test' => 1]; $intersection = $traversable->difference($otherData); $this->assertMatches($intersection, array_diff($data, $otherData)); }