<commit_before><?php

namespace oopapi;

abstract class RequestHandler implements Invokable {
    private $successor;
    
    public function __construct(RequestHandler $successor = NULL) {
        $this->successor = $successor;
    }
    
    public function __invoke() {
        if (isset($this->successor)) {
            $this->successor();
        }
    }
}<commit_msg>Add methods<commit_after><?php

namespace oopapi;

abstract class RequestHandler implements Invokable {
    private $successor;
    
    public function __construct(RequestHandler $successor = NULL) {
        $this->successor = $successor;
    }
    
    public function __invoke() {
        try {
            $retval = $this->invoke();
        } catch (Exception $e) {
            $this->fail($e);
            return;
        }
        $this->pass($retval);
    }
    
    abstract protected function invoke();

    protected function pass($retval) {
        if (isset($this->successor)) {
            $this->successor();
        }
    }
    
    protected function fail(\Exception $e) {
        throw $e;
    }
}
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.0, 'mean_word_length': 2.111428571428571, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '1422659', 'n_tokens_mistral': 305, 'n_tokens_neox': 304, 'n_words': 69}