Example #1
0
 /**
  * Intersect two Collection
  * @param Collection $collection
  * @return Collection
  */
 public function intersect(Collection $collection)
 {
     $newCollection = $this->newInstance();
     $this->each(function (Collectable $collectable) use($newCollection, $collection) {
         if ($collection->containsIndex($collectable->getIndex())) {
             $newCollection->append($collectable);
         }
     });
     return $newCollection;
 }