Skip to content

Commit

Permalink
+ Seed::chain()
Browse files Browse the repository at this point in the history
Replaces Seed::merged which becomes its alias.
  • Loading branch information
dakujem committed Feb 21, 2024
1 parent b633676 commit fb31fbb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@
final class Seed
{
/**
* Create a merged iterable.
* Chain multiple iterable collections into a single one.
* The input collections are not actually merged, but a generator is produced.
*
* Can be used to prepend or append data from multiple source collections.
* The data is not actually merged, but a generator is produced.
*/
public static function merged(iterable ...$input): Generator
public static function chain(iterable ...$input): Generator
{
foreach ($input as $iterable) {
yield from $iterable;
}
}

/**
* An alias of `chain`.
*
* Creates a "merged" iterable from multiple collections.
* The input collections are not actually merged, but a generator is produced.
*/
public static function merged(iterable ...$input): Generator
{
return self::chain(...$input);
}

/**
* Prepend `null` value at the beginning of the data collection.
* Use when missing root.
Expand Down

0 comments on commit fb31fbb

Please sign in to comment.