<commit_before><?php
/**
 * Bootstrapping
 */

// autoloader
require '../vendor/autoload.php';

// environment variables
josegonzalez\Dotenv\Loader::load([
    'filepath' => dirname(__DIR__) . DIRECTORY_SEPARATOR . '.env',
    'toEnv' => true,
]);

// action-domain-responder object
$boot = new Radar\Adr\Boot();
$adr = $boot->adr();

/**
 * Setup
 */

// middleware handlers
$adr->middle('Radar\Adr\Handler\RoutingHandler');
$adr->middle('Radar\Adr\Handler\ActionHandler');
$adr->middle('Radar\Adr\Handler\SendingHandler');

// routes
$adr->get('Hello', '/{name}?', function (array $input) {
        $payload = new Aura\Payload\Payload();
        return $payload
            ->setStatus($payload::SUCCESS)
            ->setOutput([
                'phrase' => 'Hello ' . $input['name']
            ]);
    })
    ->defaults(['name' => 'world']);

/**
 * Run
 */
$adr->run(
    Zend\Diactoros\ServerRequestFactory::fromGlobals(),
    new Zend\Diactoros\Response()
);
<commit_msg>add exception handler to the pipeline<commit_after><?php
/**
 * Bootstrapping
 */

// autoloader
require '../vendor/autoload.php';

// environment variables
josegonzalez\Dotenv\Loader::load([
    'filepath' => dirname(__DIR__) . DIRECTORY_SEPARATOR . '.env',
    'toEnv' => true,
]);

// action-domain-responder object
$boot = new Radar\Adr\Boot();
$adr = $boot->adr();

/**
 * Setup
 */

// pipeline middleware
$adr->middle('Radar\Adr\Handler\ExceptionHandler');
$adr->middle('Radar\Adr\Handler\RoutingHandler');
$adr->middle('Radar\Adr\Handler\ActionHandler');
$adr->middle('Radar\Adr\Handler\SendingHandler');

// routes
$adr->get('Hello', '/{name}?', function (array $input) {
        $payload = new Aura\Payload\Payload();
        return $payload
            ->setStatus($payload::SUCCESS)
            ->setOutput([
                'phrase' => 'Hello ' . $input['name']
            ]);
    })
    ->defaults(['name' => 'world']);

/**
 * Run
 */
$adr->run(
    Zend\Diactoros\ServerRequestFactory::fromGlobals(),
    new Zend\Diactoros\Response()
);

{'fraction_non_alphanumeric': 0.2030481809242871, 'fraction_numerical': 0.0, 'mean_word_length': 3.127789046653144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '5849414', 'n_tokens_mistral': 684, 'n_tokens_neox': 672, 'n_words': 106}