<commit_before><?php

if (!defined("KAKU_ACCESS")) {

  // Deny direct access to this file.
  exit();
}

class Hook {

  private $actions;
  private $filters;

  private $action_objects;
  private $filter_objects;
  private $filter_methods;

  public function __construct() {

    $this->actions = [];
    $this->filters = [];

    $this->action_objects = [];
    $this->filter_objects = [];
    $this->filter_methods = [];
  }

  public function doAction($action) {

    if (in_array($action, $this->actions)) {

      if (array_key_exists($action, $this->filters)) {

        // Get the contents of the original action.
        $callback = $this->action_objects[$action];

        for ($i = 0; $i < count($this->filters[$action]); ++$i) {

          // Pass the callback to filter methods to be manipulated.
          $callback = call_user_func(

            [

              $this->filter_objects[$action][$i],

              $this->filter_methods[$action][$i]
            ],

            $callback
          );
        }

        // Return the modified contents of the action.
        return $callback;
      }
      else {

        // Return the original contents of the action.
        return $this->action_objects[$action];
      }
    }
  }

  public function addAction($action, $object) {

    if (!in_array($action, $this->actions)) {

      $this->actions[$action] = $action;

      $this->action_objects[$action] = $object;
    }
  }

  public function addFilter($action, $object, $method) {

    if (!isset($this->filters[$action])) {

      $this->filters[$action] = [];
    }

    if (!isset($this->filter_objects[$action])) {

      $this->filter_objects[$action] = [];
    }

    if (!isset($this->filter_methods[$action])) {

      $this->filter_methods[$action] = [];
    }

    $this->filters[$action][] = $action;

    $this->filter_objects[$action][] = $object;
    $this->filter_methods[$action][] = $method;
  }
}

?>
<commit_msg>Get name of class that adds filter<commit_after><?php

if (!defined("KAKU_ACCESS")) {

  // Deny direct access to this file.
  exit();
}

class Hook {

  private $actions;
  private $filters;
  private $filter_classes;
  private $filter_objects;
  private $filter_methods;
  private $action_contents;

  public function __construct() {

    $this->actions = [];
    $this->filters = [];
    $this->filter_classes = [];
    $this->filter_objects = [];
    $this->filter_methods = [];
    $this->action_contents = [];
  }

  public function doAction($action) {

    if (in_array($action, $this->actions)) {

      if (array_key_exists($action, $this->filters)) {

        // Get the contents of the original action.
        $callback = $this->action_contents[$action];

        for ($i = 0; $i < count($this->filters[$action]); ++$i) {

          // Pass the callback to filter methods to be manipulated.
          $callback = call_user_func(

            [

              $this->filter_classes[$action][$i],

              $this->filter_methods[$action][$i]
            ],

            $callback
          );
        }

        // Return the modified contents of the action.
        return $callback;
      }
      else {

        // Return the original contents of the action.
        return $this->action_contents[$action];
      }
    }
  }

  public function addAction($action, $contents) {

    if (!in_array($action, $this->actions)) {

      $this->actions[$action] = $action;

      $this->action_contents[$action] = $contents;
    }
  }

  public function addFilter($action, $method) {

    if (!isset($this->filters[$action])) {

      $this->filters[$action] = [];
    }

    if (!isset($this->filter_classes[$action])) {

      $this->filter_classes[$action] = [];
    }

    if (!isset($this->filter_objects[$action])) {

      $this->filter_objects[$action] = [];
    }

    if (!isset($this->filter_methods[$action])) {

      $this->filter_methods[$action] = [];
    }

    $this->filters[$action][] = $action;

    $this->filter_methods[$action][] = $method;

    // Get the name of the class that added the filter.
    $this->filter_classes[$action][] = debug_backtrace()[1]["class"];
  }
}

?>

{'fraction_non_alphanumeric': 0.16754680748919829, 'fraction_numerical': 0.0007201152184349496, 'mean_word_length': 2.4899497487437188, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 56, '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': '6304712', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1229, 'n_words': 257}