Example #1
0
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $_func = $this->func;
     foreach ($c->generate() as $key => $item) {
         $_func($item, $key, $c);
     }
     return $c;
 }
Example #2
0
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $_func = $this->func;
     $acc = $this->acc;
     foreach ($c->generate() as $key => $item) {
         $acc = $_func($acc, $item, $key, $c);
     }
     return new Collection([$acc]);
 }
Example #3
0
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $_func = $this->func;
     $newCollection = new Collection();
     foreach ($c->generate() as $item) {
         $newCollection->append($_func($item));
     }
     return $newCollection;
 }