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;
 }
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $_func = $this->func;
     $acc = $this->acc;
     foreach ($c->rgenerate() 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;
 }
Example #4
0
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $a = $c->toArray();
     asort($a, $this->sort_flags);
     return new Collection($a);
 }
Example #5
0
 /**
  * apply operation to list
  *
  * @param Collection $c
  * @return Collection
  */
 public function apply($c) : Collection
 {
     $a = $c->toArray();
     uasort($a, $this->compare_func);
     return new Collection($a);
 }