<commit_before><?php
/**
 * @package BaseX 
 * 
 * @copyright Copyright (c) 2012, <NAME>
 * @author <NAME> <<EMAIL>>
 * @license BSD License
 */

namespace BaseX\Resource\Iterator;

use ArrayIterator;
use FilterIterator;
use InvalidArgumentException;
use Traversable;

/**
 * CallbackFilterIterator for php 5.3
 *
 * @author alxarch
 */
class CallbackFilter extends FilterIterator
{
  protected $callback;
  
  /**
   *
   * @var ArrayIterator
   */
  protected $array;
  
  public function __construct(Traversable $iter, $callback)
  {
    parent::__construct($iter);
    
    if(!is_callable($callback))
      throw new InvalidArgumentException('Invalid Callback');
    
    $this->callback = $callback;
  }
  
  public function accept()
  {
    $resource = parent::current();
    return $this->callback($resource);
  }
}
<commit_msg>- Fix callback filter for non closure arguments<commit_after><?php
/**
 * @package BaseX 
 * 
 * @copyright Copyright (c) 2012, <NAME>
 * @author <NAME> <<EMAIL>>
 * @license BSD License
 */

namespace BaseX\Resource\Iterator;

use ArrayIterator;
use FilterIterator;
use InvalidArgumentException;
use Traversable;

/**
 * CallbackFilterIterator for php 5.3
 *
 * @author alxarch
 */
class CallbackFilter extends FilterIterator
{
  protected $callback;
  
  /**
   *
   * @var ArrayIterator
   */
  protected $array;
  
  public function __construct(Traversable $iter, $callback)
  {
    parent::__construct($iter);
    
    if(!is_callable($callback))
      throw new InvalidArgumentException('Invalid Callback');
    
    $this->callback = $callback;
  }
  
  public function accept()
  {
    $resource = parent::current();
    return call_user_func($this->callback, $resource);  }
}

{'fraction_non_alphanumeric': 0.12783265543288785, 'fraction_numerical': 0.006972690296339338, 'mean_word_length': 3.616621983914209, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3425865', 'n_tokens_mistral': 539, 'n_tokens_neox': 519, 'n_words': 128}