<commit_before><?php
/**
 * ConstraintRoute Service
 */
namespace Pupcake\Service;

use Pupcake;

class RouteConstraint extends Pupcake\Service
{
    public function start($app, $config = array())
    {
        /**
         * When a route object is being created, we add the constraint method 
         * to it and store the constraint into this route object's storage
         */
        $app->on("system.routing.route.create", function(){
            $route = new Pupcake\Route();
            $route->method('constraint', function($constraint) use($route){
                $route->storageSet('constraint', $constraint);
            });
            return $route;
        });

        /**
         * When a route object is initially matched, we add further checking logic 
         * to make sure the constraint is applying toward the route matching process
         */
        $app->on("system.routing.route.matched", function($route){
            $matched = true;
            $params = $route->getParams();
            $constraint = $route->storageGet('constraint');<commit_msg>return route instance after system.routing.route.create event<commit_after><?php
/**
 * ConstraintRoute Service
 */
namespace Pupcake\Service;

use Pupcake;

class RouteConstraint extends Pupcake\Service
{
    public function start($app, $config = array())
    {
        /**
         * When a route object is being created, we add the constraint method 
         * to it and store the constraint into this route object's storage
         */
        $app->on("system.routing.route.create", function(){
            $route = new Pupcake\Route();
            $route->method('constraint', function($constraint) use($route){
                $route->storageSet('constraint', $constraint);
                return $route; //return the route reference for futher extension
            });
            return $route;
        });

        /**
         * When a route object is initially matched, we add further checking logic 
         * to make sure the constraint is applying toward the route matching process
         */
        $app->on("system.routing.route.matched", function($route){
            $matched = true;
            $params = $route->getParams();
            $constraint = $route->storageGet('constraint');
{'fraction_non_alphanumeric': 0.11479703186381493, 'fraction_numerical': 0.0, 'mean_word_length': 2.2742857142857145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4540854', 'n_tokens_mistral': 562, 'n_tokens_neox': 549, 'n_words': 179}