@@ -63,8 +63,8 @@ declare(strict_types=1);
6363namespace Example;
6464
6565use TinyBlocks\Collection\Collection;
66- use TinyBlocks\Collection\Internal\Operations\Order\ Order;
67- use TinyBlocks\Collection\Internal\Operations\Transform\ PreserveKeys;
66+ use TinyBlocks\Collection\Order;
67+ use TinyBlocks\Collection\PreserveKeys;
6868
6969$collection = Collection::createFrom(elements: [1, 2, 3, 4, 5])
7070 ->add(elements: [6, 7])
@@ -159,7 +159,7 @@ These methods enable sorting elements in the Collection based on the specified o
159159 By default, `Order::ASCENDING_KEY` is used.
160160
161161 ```php
162- use TinyBlocks\Collection\Internal\Operations\Order\ Order;
162+ use TinyBlocks\Collection\Order;
163163
164164 $collection->sort(order: Order::DESCENDING_VALUE);
165165 ```
@@ -168,7 +168,7 @@ These methods enable sorting elements in the Collection based on the specified o
168168 compared.
169169
170170 ``` php
171- use TinyBlocks\Collection\Internal\Operations\Order\ Order;
171+ use TinyBlocks\Collection\Order;
172172
173173 $collection->sort(order: Order::ASCENDING_VALUE, predicate: fn(Amount $amount): float => $amount->value);
174174 ```
@@ -296,6 +296,18 @@ These methods allow the Collection's elements to be transformed or converted int
296296 $collection->map(transformations: fn(int $value): int => $value * 2);
297297 ```
298298
299+ #### Flattening elements
300+
301+ - ` flatten ` : Flattens a collection by removing any nested collections and returning a single collection with all
302+ elements in a single level.
303+
304+ This method recursively flattens any iterable elements, combining them into one collection, regardless of their
305+ nesting depth.
306+
307+ ``` php
308+ $collection->flatten();
309+ ```
310+
299311#### Convert to array
300312
301313- ` toArray ` : Converts the Collection into an array.
@@ -308,7 +320,7 @@ These methods allow the Collection's elements to be transformed or converted int
308320 By default, ` PreserveKeys::PRESERVE ` is used.
309321
310322 ``` php
311- use TinyBlocks\Collection\Internal\Operations\Transform\ PreserveKeys;
323+ use TinyBlocks\Collection\PreserveKeys;
312324
313325 $collection->toArray(preserveKeys: PreserveKeys::DISCARD);
314326 ```
@@ -325,7 +337,7 @@ These methods allow the Collection's elements to be transformed or converted int
325337 By default, ` PreserveKeys::PRESERVE ` is used.
326338
327339 ``` php
328- use TinyBlocks\Collection\Internal\Operations\Transform\ PreserveKeys;
340+ use TinyBlocks\Collection\PreserveKeys;
329341
330342 $collection->toJson(preserveKeys: PreserveKeys::DISCARD);
331343 ```
@@ -352,8 +364,8 @@ Lazy evaluation, enabled by [PHP's Generators](https://www.php.net/manual/en/lan
352364This results in significant memory savings when working with large datasets or performing complex
353365chained operations.
354366
355- However, this also means that some operations will entirely consume the generator, and you won't be
356- able to reaccess the elements unless you recreate the ` Collection ` .
367+ However, this also means that some operations will consume the generator, and you cannot access the elements unless you
368+ recreate the ` Collection ` .
357369
358370<div id =' license ' ></div >
359371
0 commit comments