From 5a3c1118271724c71e1283eb9cf12e469d92731c Mon Sep 17 00:00:00 2001 From: Andrej Rypo Date: Wed, 21 Feb 2024 11:47:21 +0100 Subject: [PATCH] + Seed::chain() Replaces Seed::merged which becomes its alias. --- changelog.md | 5 +++++ src/Seed.php | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index bd096bb..ca10222 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/Seed.php b/src/Seed.php index 6bc068c..ccb9e09 100644 --- a/src/Seed.php +++ b/src/Seed.php @@ -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.