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 5a3c111
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Oliva follows semantic versioning.\
Please report any issues.


## v1.1.x

- Added `Seed::chain` method for iterable collection chaining: the new method takes over `Seed::merged` which becomes its alias.


## v1.0

The initial release.
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 5a3c111

Please sign in to comment.