original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Retrieve duplicate items from the collection.
  
  @param  callable|null  $callback
  @param  bool  $strict
  @return static
docstring_tokens: Retrieve duplicate items from the collection .