for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* File was created 06.05.2015 22:14
*
* @author Karsten J. Gerber <[email protected]>
*/
namespace PeekAndPoke\Component\Psi\Operation\FullSet;
use PeekAndPoke\Component\Psi\FullSetOperation;
* UniqueOperation
class UniqueOperation implements FullSetOperation
{
/** @var bool */
protected $strict;
* @param bool $strict
public function __construct($strict)
$this->strict = (bool) $strict;
}
* {@inheritdoc}
public function apply(\Iterator $set)
$result = [];
foreach ($set as $item) {
if (! in_array($item, $result, $this->strict)) {
$result[] = $item;
return new \ArrayIterator($result);