From dff7e1bd510da5b1e446b75222b034ba1411e2a9 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 25 Aug 2021 08:07:04 +0200 Subject: [PATCH] refactor: Update `Duplicateable` interface. --- src/Contract/Operation/Duplicateable.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Contract/Operation/Duplicateable.php b/src/Contract/Operation/Duplicateable.php index 8558854d1..0ea9dbeb8 100644 --- a/src/Contract/Operation/Duplicateable.php +++ b/src/Contract/Operation/Duplicateable.php @@ -19,9 +19,23 @@ interface Duplicateable { /** * Find duplicated values from the collection. + * The operation has 2 optional parameters that allow you to customize precisely + * how values are accessed and compared to each other. + * + * The first parameter is the comparator. This is a curried function which takes + * first the left part, then the right part and then returns a boolean. + * + * The second parameter is the accessor. This binary function takes the value and the key + * of the current iterated value and then return the value to compare. + * This is useful when you want to compare objects. * * @see https://loophp-collection.readthedocs.io/en/stable/pages/api.html#duplicate * + * @template U + * + * @param null|callable(U): (Closure(U): bool) $comparatorCallback + * @param null|callable(T, TKey): U $accessorCallback + * * @return Collection */ public function duplicate(?callable $comparatorCallback = null, ?callable $accessorCallback = null): Collection;