src/Collection/ArrayCollection.php
public function keyBy(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$callback($value, $key)] = $value;
        }

        return new static($items);
    }
public function keyBy(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$callback($value, $key)] = $value;
        }

        return new static($items);
    }
public function keyBy ( callable $ callback ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { $ items [ $ callback ( $ value , $ key ) ] = $ value ; } return new static ( $ items ) ; }
Creates a collection keyed by keys from a callback

Callback signature:

<code>
function ($value, $key): mixed {}
</code>

@param callable $callback The callback function

@return ArrayCollection
Creates a collection keyed by keys from a callback