Skip to content

Commit

Permalink
Update Chunk operation
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 27, 2020
1 parent b071823 commit 1260974
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ public function cache(?CacheItemPoolInterface $cache = null): CollectionInterfac
return $this->run(new Cache($cache ?? new ArrayAdapter()));
}

public function chunk(int ...$size): CollectionInterface
public function chunk(int ...$sizes): CollectionInterface
{
return $this->run(new Chunk(...$size));
return $this->run(new Chunk(...$sizes));
}

public function collapse(): CollectionInterface
Expand Down
4 changes: 1 addition & 3 deletions src/Contract/Operation/Chunkable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ interface Chunkable
/**
* Chunk the collection into chunks of the given size.
*
* @param int ...$size
*
* @psalm-return \loophp\collection\Contract\Collection<TKey, T>
*/
public function chunk(int ...$size): Collection;
public function chunk(int ...$sizes): Collection;
}
8 changes: 3 additions & 5 deletions src/Operation/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
*/
final class Chunk extends AbstractOperation implements Operation
{
public function __construct(int ...$size)
public function __construct(int ...$sizes)
{
$this->storage['size'] = new ArrayIterator($size);
$this->storage['sizes'] = new ArrayIterator($sizes);
}

/**
* @psalm-template U
*
* @psalm-return \Closure(\Iterator<TKey, T>, list<int>):(\Generator<int, list<T>>)
* @psalm-return Closure(Iterator<TKey, T>, list<int>):(Generator<int, list<T>>)
*/
public function __invoke(): Closure
{
Expand Down

0 comments on commit 1260974

Please sign in to comment.