src/Collection/ArrayCollection.php
public function partition(callable $predicate): ArrayCollection
    {
        $items1 = [];
        $items2 = [];

        foreach ($this->items as $key => $value) {
            if ($predicate($value, $key)) {
                $items1[$key] = $value;
            } else {
                $items2[$key] = $value;
            }
        }

        return new static([new static($items1), new static($items2)]);
    }
public function partition(callable $predicate): ArrayCollection
    {
        $items1 = [];
        $items2 = [];

        foreach ($this->items as $key => $value) {
            if ($predicate($value, $key)) {
                $items1[$key] = $value;
            } else {
                $items2[$key] = $value;
            }
        }

        return new static([new static($items1), new static($items2)]);
    }
public function partition ( callable $ predicate ) : ArrayCollection { $ items1 = [ ] ; $ items2 = [ ] ; foreach ( $ this -> items as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { $ items1 [ $ key ] = $ value ; } else { $ items2 [ $ key ] = $ value ; } } return new static ( [ new static ( $ items1 ) , new static ( $ items2 ) ] ) ; }
Creates a collection of two collections based on a truth test

Items that pass the truth test are placed in the first collection.

Items that fail the truth test are placed in the second collection.

Predicate signature:

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

@param callable $predicate The predicate function

@return ArrayCollection
Creates a collection of two collections based on a truth test