public function duplicates($callback = null, $strict = false)
    {
        $items = $this->map($this->valueRetriever($callback));

        $uniqueItems = $items->unique(null, $strict);

        $compare = $this->duplicateComparator($strict);

        $duplicates = new static;

        foreach ($items as $key => $value) {
            if ($uniqueItems->isNotEmpty() && $compare($value, $uniqueItems->first())) {
                $uniqueItems->shift();
            } else {
                $duplicates[$key] = $value;
            }
        }

        return $duplicates;
    }
public function duplicates($callback = null, $strict = false)
    {
        $items = $this->map($this->valueRetriever($callback));

        $uniqueItems = $items->unique(null, $strict);

        $compare = $this->duplicateComparator($strict);

        $duplicates = new static;

        foreach ($items as $key => $value) {
            if ($uniqueItems->isNotEmpty() && $compare($value, $uniqueItems->first())) {
                $uniqueItems->shift();
            } else {
                $duplicates[$key] = $value;
            }
        }

        return $duplicates;
    }
public function duplicates ( $ callback = null , $ strict = false ) { $ items = $ this -> map ( $ this -> valueRetriever ( $ callback ) ) ; $ uniqueItems = $ items -> unique ( null , $ strict ) ; $ compare = $ this -> duplicateComparator ( $ strict ) ; $ duplicates = new static ; foreach ( $ items as $ key => $ value ) { if ( $ uniqueItems -> isNotEmpty ( ) && $ compare ( $ value , $ uniqueItems -> first ( ) ) ) { $ uniqueItems -> shift ( ) ; } else { $ duplicates [ $ key ] = $ value ; } } return $ duplicates ; }
Retrieve duplicate items from the collection.

@param  callable|null  $callback
@param  bool  $strict
@return static
Retrieve duplicate items from the collection .