Ejemplo n.º 1
0
 /**
  * Process filter
  * @param  callable                     $closure
  * @return \Kohkimakimoto\EArray\EArray
  */
 public function filter($closure)
 {
     if (!$closure instanceof \Closure) {
         throw new \RuntimeException("The argument must be a closure");
     }
     $new = new EArray();
     foreach ($this as $key => $value) {
         if (call_user_func($closure, $key, $value)) {
             $rawValue = $this->getRawValue($key);
             $new->set($key, $rawValue);
         }
     }
     return $new;
 }