public function map($callback, $data = false)
    {
      $collection = $this->getIterator();
      $mutatedCollection = new Collection();

      foreach($collection as $prop => $result) {
        // Prep data to pass to closure
        $funcArgs = is_array($data) ? $data : [$data];
        array_unshift($funcArgs, $prop);
        array_unshift($funcArgs, $result);
        
        $aValue = call_user_func_array($callback, $funcArgs);
        $mutatedCollection->add($aValue);
      }
      return $mutatedCollection;
    }
public function map($callback, $data = false)
    {
      $collection = $this->getIterator();
      $mutatedCollection = new Collection();

      foreach($collection as $prop => $result) {
        // Prep data to pass to closure
        $funcArgs = is_array($data) ? $data : [$data];
        array_unshift($funcArgs, $prop);
        array_unshift($funcArgs, $result);
        
        $aValue = call_user_func_array($callback, $funcArgs);
        $mutatedCollection->add($aValue);
      }
      return $mutatedCollection;
    }
public function map ( $ callback , $ data = false ) { $ collection = $ this -> getIterator ( ) ; $ mutatedCollection = new Collection ( ) ; foreach ( $ collection as $ prop => $ result ) { // Prep data to pass to closure $ funcArgs = is_array ( $ data ) ? $ data : [ $ data ] ; array_unshift ( $ funcArgs , $ prop ) ; array_unshift ( $ funcArgs , $ result ) ; $ aValue = call_user_func_array ( $ callback , $ funcArgs ) ; $ mutatedCollection -> add ( $ aValue ) ; } return $ mutatedCollection ; }
Map callback to data.

@param callback A callable function.
@return A collection
Map callback to data .