| Total Complexity | 3 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class DistinctStream extends FilterIterator implements StreamInterface |
||
| 14 | { |
||
| 15 | use StreamTrait; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var SetInterface |
||
| 19 | */ |
||
| 20 | private $set; |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * FilterStream constructor. |
||
| 25 | * |
||
| 26 | * @param StreamInterface $stream The stream to filter |
||
| 27 | * @param SetInterface $set The set used to store elements |
||
| 28 | */ |
||
| 29 | 30 | public function __construct(StreamInterface $stream, SetInterface $set) |
|
| 30 | { |
||
| 31 | 30 | parent::__construct($stream); |
|
| 32 | |||
| 33 | 30 | $this->set = $set; |
|
| 34 | 30 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | 30 | public function accept(): bool |
|
| 40 | { |
||
| 41 | 30 | return $this->set->add($this->current()); |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | 30 | public function rewind(): void |
|
| 52 | 30 | } |
|
| 53 | } |
||
| 54 |