Innmind /
Immutable
| 1 | <?php |
||
| 2 | declare(strict_types = 1); |
||
| 3 | |||
| 4 | namespace Fixtures\Innmind\Immutable; |
||
| 5 | |||
| 6 | use Innmind\BlackBox\Set as DataSet; |
||
| 7 | use Innmind\Immutable\{ |
||
| 8 | Set as Structure, |
||
| 9 | Sequence as ISequence, |
||
| 10 | }; |
||
| 11 | |||
| 12 | final class Set |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @template I |
||
| 16 | * |
||
| 17 | * @param Set<I> $set |
||
| 18 | * |
||
| 19 | * @return Set<Structure<I>> |
||
| 20 | */ |
||
| 21 | public static function of(DataSet $set, DataSet\Integers $sizes = null): DataSet |
||
| 22 | { |
||
| 23 | return DataSet\Decorate::immutable( |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 24 | static fn(array $values): Structure => Structure::of(...$values), |
||
| 25 | DataSet\Sequence::of( |
||
| 26 | $set, |
||
| 27 | $sizes, |
||
| 28 | )->filter(static function(array $values): bool { |
||
| 29 | // checks unicity of values |
||
| 30 | return ISequence::mixed(...$values)->size() === Structure::mixed(...$values)->size(); |
||
| 31 | }), |
||
| 32 | ); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |