A collector can be thought of as a stateful reductor. It is initialized (in some way) and then elements are insterted one by one. Finally, the result is queried in the get method.
Author: Bert Peters (bert.ljpeters@gmail.com)
Example #1
0
 public function collect(Collector $collector)
 {
     foreach ($this as $key => $value) {
         $collector->add($key, $value);
     }
     return $collector->get();
 }