From fb31fbb2a94d05a46f4a87c98f7c26baf486fff5 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. --- src/Seed.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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.