<commit_before><?php namespace Stubborn;

use Belt\Trace;

use Stubborn\Exceptions\StubbornException;
use Stubborn\Events\StopEvent;
use Stubborn\Events\RetryEvent;
use Stubborn\Events\BackoffEvent;
use Stubborn\Events\DelayRetryEvent;
use Stubborn\Events\ResetEvent;

/**
 *  Stubborn is designed to execute functions that require a higher level of 
 *  robustness and configurability against exceptions and backoff for when 
 *  there is the risk of mission critical infrastructure failing for variable 
 *  or unknown reasoning against blackbox systems.
 *
 *  //TODO: v3 needs to better support an array of functions to run, although 
 *  for now that seems like a bit of an edge case
 */
class Stubborn
{
    // User Defined Handlers
    protected $event_handler_class;
    protected $result_handler;
    protected $exception_handler;
    
    // User Defined Configuration Properties
    protected $catchable_exceptions;
    protected $short_circuit;

    // Run State Properties
    protected $current_invokable;
    protected $retry_count;
    protected $max_retries;
    protected $current_result;
    protected $current_exception;
    protected $start_time;
    protected $run_time;
    protected $total_backoff;

    /**
     *  Creates a Stubborn object with some default parameters for plug and 
     *  play capabilities. Any custom setting should happen using the setters 
     *  defined below.
     */
    public function __construct()
    {
        // Stubborn configuration
        $this->current_invokable = null;
        $this->catchable_exceptions = array();
        $this->short_circuit = false;
        $this->max_retries = 0;
        $this->retry_count = 0;
        $this->current_exception = null;
        $this->current_result = null;
        $this->run_time = 0;
        $this->total_backoff = 0;
        $this->result_handler = null;
        $this->exception_handler = null;
        $this->event_handler_class = 'Stubborn\EventHandler';<commit_msg>Changed how eventhandler is specified<commit_after><?php namespace Stubborn;

use Belt\Trace;

use Stubborn\Exceptions\StubbornException;
use Stubborn\Events\StopEvent;
use Stubborn\Events\RetryEvent;
use Stubborn\Events\BackoffEvent;
use Stubborn\Events\DelayRetryEvent;
use Stubborn\Events\ResetEvent;

/**
 *  Stubborn is designed to execute functions that require a higher level of 
 *  robustness and configurability against exceptions and backoff for when 
 *  there is the risk of mission critical infrastructure failing for variable 
 *  or unknown reasoning against blackbox systems.
 *
 *  //TODO: v3 needs to better support an array of functions to run, although 
 *  for now that seems like a bit of an edge case
 */
class Stubborn
{
    // User Defined Handlers
    protected $event_handler_class;
    protected $result_handler;
    protected $exception_handler;
    
    // User Defined Configuration Properties
    protected $catchable_exceptions;
    protected $short_circuit;

    // Run State Properties
    protected $current_invokable;
    protected $retry_count;
    protected $max_retries;
    protected $current_result;
    protected $current_exception;
    protected $start_time;
    protected $run_time;
    protected $total_backoff;

    /**
     *  Creates a Stubborn object with some default parameters for plug and 
     *  play capabilities. Any custom setting should happen using the setters 
     *  defined below.
     */
    public function __construct($event_handler_class = 'Stubborn\EventHandler')
    {
        // Stubborn configuration
        $this->current_invokable = null;
        $this->catchable_exceptions = array();
        $this->short_circuit = false;
        $this->max_retries = 0;
        $this->retry_count = 0;
        $this->current_exception = null;
        $this->current_result = null;
        $this->run_time = 0;
        $this->total_backoff = 0;
        $this->result_handler = null;
        $this->exception_handler = null;
        $this->event_handler_class = $event_handler_class;
{'fraction_non_alphanumeric': 0.07833872171101716, 'fraction_numerical': 0.002486943546381497, 'mean_word_length': 3.1939520333680917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '2307738', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1122, 'n_words': 342}