Skip to content

Commit

Permalink
Merge 9ba5738 into 8a67fad
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Apr 11, 2023
2 parents 8a67fad + 9ba5738 commit 1252a81
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ public function unpack(?callable $func = null): self
});
}

/**
* Flattens inputs: arrays become lists.
*/
public function flatten(): self
{
return $this->unpack();
}

/**
* Chunks the pipeline into arrays with length elements. The last chunk may contain less than length elements.
*
Expand Down
12 changes: 12 additions & 0 deletions tests/UnpackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@ public function testWithIterator(): void
[3],
])->unpack()->toArray());
}

/**
* @covers \Pipeline\Standard::flatten()
*/
public function testFlatten(): void
{
$this->assertSame([1, 2, 3], fromArray([
new ArrayIterator([1]),
fromArray([2]),
[3],
])->flatten()->toArray());
}
}

0 comments on commit 1252a81

Please sign in to comment.