<commit_before><?php
include_once "../vendor/autoload.php";

$text = '<esi:include src="http://crazy-goat.com/octophpus/test/error_404"/>';

$reject_closure = function (string &$data, array $esiRequests) {
    return (function (\Exception $reason, int $index) use (&$data, $esiRequests) {
        var_dump($reason->getCode());
    });
};

$mantle = new \CrazyGoat\Octophpus\Mantle(
    ['on_reject' => $reject_closure ]
);
echo $mantle->decorate($text);
<commit_msg>fix example code<commit_after><?php
include_once "../vendor/autoload.php";

$text = '<esi:include src="http://crazy-goat.com/octophpus/test/error_404"/>';
/**
 * @param string $data
 * @param \CrazyGoat\Octophpus\EsiRequest[] $esiRequests
 * @return Closure
 */
$reject_closure = function (string &$data, array $esiRequests) {
    return (function (\Exception $reason, int $index) use (&$data, $esiRequests) {
        echo "Unable to fetch request (".$esiRequests[$index]->getSrc().") reason : ".$reason->getMessage();
        $reason;
    });
};

$mantle = new \CrazyGoat\Octophpus\Mantle(
    ['on_reject' => $reject_closure]
);

echo $mantle->decorate($text);

{'fraction_non_alphanumeric': 0.19309123117803365, 'fraction_numerical': 0.005314437555358724, 'mean_word_length': 4.458937198067633, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5880557', 'n_tokens_mistral': 396, 'n_tokens_neox': 398, 'n_words': 76}