diff --git a/spec/loophp/collection/CollectionSpec.php b/spec/loophp/collection/CollectionSpec.php index 79029b198..7863fe692 100644 --- a/spec/loophp/collection/CollectionSpec.php +++ b/spec/loophp/collection/CollectionSpec.php @@ -264,11 +264,11 @@ public function it_can_combine(): void ->beConstructedThrough('with', [range('A', 'E')]); $this - ->combine(range('e', 'a')) + ->combine(...range('e', 'a')) ->shouldIterateAs(['e' => 'A', 'd' => 'B', 'c' => 'C', 'b' => 'D', 'a' => 'E']); $this - ->combine(range(1, 100)) + ->combine(...range(1, 100)) ->shouldThrow(Exception::class) ->during('all'); } diff --git a/src/Collection.php b/src/Collection.php index bb691dc94..491d1ad7c 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -116,9 +116,9 @@ public function collapse(): BaseInterface * * @return \loophp\collection\Contract\Collection */ - public function combinate(?int $size = null): BaseInterface + public function combinate(?int $length = null): BaseInterface { - return $this->run(new Combinate($size)); + return $this->run(new Combinate($length)); } /** @@ -126,7 +126,7 @@ public function combinate(?int $size = null): BaseInterface * * @return \loophp\collection\Contract\Collection */ - public function combine($keys): BaseInterface + public function combine(...$keys): BaseInterface { return $this->run(new Combine($keys)); } @@ -182,9 +182,9 @@ public static function empty(): CollectionInterface * * @return \loophp\collection\Contract\Collection */ - public function explode(string ...$strings): BaseInterface + public function explode(...$explodes): BaseInterface { - return $this->run(new Explode(...$strings)); + return $this->run(new Explode(...$explodes)); } /** diff --git a/src/Contract/Applyable.php b/src/Contract/Applyable.php index cac9951d5..d00fa8245 100644 --- a/src/Contract/Applyable.php +++ b/src/Contract/Applyable.php @@ -5,12 +5,12 @@ namespace loophp\collection\Contract; /** - * Interface Appendable. + * Interface Applyable. */ interface Applyable { /** - * Apply a callback to all the element of an array. + * Execute a callback for each element of the collection. * * @param callable ...$callables * diff --git a/src/Contract/Collapseable.php b/src/Contract/Collapseable.php index 2eab1bcef..8d29aec62 100644 --- a/src/Contract/Collapseable.php +++ b/src/Contract/Collapseable.php @@ -10,7 +10,7 @@ interface Collapseable { /** - * Collapse the collection of items into a single array. + * Collapse a collection of items into a simple flat collection. * * @return \loophp\collection\Contract\Collection */ diff --git a/src/Contract/Combinateable.php b/src/Contract/Combinateable.php index 316f6b765..644770d16 100644 --- a/src/Contract/Combinateable.php +++ b/src/Contract/Combinateable.php @@ -10,11 +10,12 @@ interface Combinateable { /** - * TODO: Combinations. + * Get all the combinations of a given length of a collection of items. * - * @param int $size + * @param int $length + * The length. * * @return \loophp\collection\Contract\Collection */ - public function combinate(?int $size = null): Base; + public function combinate(?int $length = null): Base; } diff --git a/src/Contract/Combineable.php b/src/Contract/Combineable.php index 47953f5d8..63545225f 100644 --- a/src/Contract/Combineable.php +++ b/src/Contract/Combineable.php @@ -10,9 +10,11 @@ interface Combineable { /** - * @param mixed $keys + * Combine a collection of items with some other keys. + * + * @param mixed ...$keys * * @return \loophp\collection\Contract\Collection */ - public function combine($keys): Base; + public function combine(...$keys): Base; } diff --git a/src/Contract/Distinctable.php b/src/Contract/Distinctable.php index 7a1b72c98..236cbe3d7 100644 --- a/src/Contract/Distinctable.php +++ b/src/Contract/Distinctable.php @@ -10,6 +10,8 @@ interface Distinctable { /** + * Remove duplicated values from a collection. + * * @return \loophp\collection\Contract\Base */ public function distinct(): Base; diff --git a/src/Contract/Explodeable.php b/src/Contract/Explodeable.php index 9c76da097..d8e0e845a 100644 --- a/src/Contract/Explodeable.php +++ b/src/Contract/Explodeable.php @@ -10,9 +10,11 @@ interface Explodeable { /** - * @param string ...$explodes + * Explode a collection into subsets based on a given value. + * + * @param mixed ...$explodes * * @return \loophp\collection\Contract\Collection */ - public function explode(string ...$explodes): Base; + public function explode(...$explodes): Base; } diff --git a/src/Contract/Filterable.php b/src/Contract/Filterable.php index 613871311..980633325 100644 --- a/src/Contract/Filterable.php +++ b/src/Contract/Filterable.php @@ -10,7 +10,7 @@ interface Filterable { /** - * Run a filter over each of the items. + * Filter collection items based on one or more callbacks. * * @param callable ...$callbacks * diff --git a/src/Operation/Combinate.php b/src/Operation/Combinate.php index 7f6e2001a..5b6ee79e5 100644 --- a/src/Operation/Combinate.php +++ b/src/Operation/Combinate.php @@ -24,7 +24,7 @@ final class Combinate implements Operation private $length; /** - * Permutations constructor. + * Combinate constructor. * * @param int $length */ diff --git a/src/Operation/Explode.php b/src/Operation/Explode.php index 3e455c4fd..fabd92339 100644 --- a/src/Operation/Explode.php +++ b/src/Operation/Explode.php @@ -13,16 +13,16 @@ final class Explode implements Operation { /** - * @var string[] + * @var array */ private $explodes; /** * Explode constructor. * - * @param string ...$explodes + * @param mixed ...$explodes */ - public function __construct(string ...$explodes) + public function __construct(...$explodes) { $this->explodes = $explodes; }