<commit_before><?php

namespace CatLab\Charon\Laravel\Transformers;

use CatLab\Charon\Collections\RouteCollection;
use CatLab\Charon\Laravel\Middleware\InputTransformer;
use CatLab\Charon\Laravel\Middleware\InputValidator;
use CatLab\Charon\Library\TransformerLibrary;
use CatLab\Charon\Transformers\ArrayTransformer;
use \Route;

/**
 * Class RouteTransformer
 * @package CatLab\RESTResource\Laravel\Transformers
 */
class RouteTransformer
{
    /**
     * RouteTransformer constructor.
     */
    public function __construct()
    {
    }

    /**
     * @param RouteCollection $routes
     * @return void
     * @throws \CatLab\Charon\Exceptions\InvalidTransformer
     */
    public function transform(RouteCollection $routes)
    {
        foreach ($routes->getRoutes() as $route) {
            $options = $route->getOptions();
            $action = $route->getAction();

            $laravelRoute = Route::match([ $route->getHttpMethod() ], $route->getPath(), $action);

            // The InputTransformer middleware makes sure that the parameters that require a
            // transformation (for example DateTimes) are transformed before the controller takes charge.
            foreach ($route->getParameters() as $parameter) {

                // Now check if the parameter has an array
                if ($parameter->getTransformer()) {

                    $middleware = $this->getTransformerMiddlewareParameters(
                        $parameter->getIn(),
                        $parameter->getType(),<commit_msg>Body parameters should never be validated or transformed in middleware.<commit_after><?php

namespace CatLab\Charon\Laravel\Transformers;

use CatLab\Charon\Collections\RouteCollection;
use CatLab\Charon\Laravel\Middleware\InputTransformer;
use CatLab\Charon\Laravel\Middleware\InputValidator;
use CatLab\Charon\Library\TransformerLibrary;
use CatLab\Charon\Models\Routing\Parameters\Base\Parameter;
use CatLab\Charon\Transformers\ArrayTransformer;
use \Route;

/**
 * Class RouteTransformer
 * @package CatLab\RESTResource\Laravel\Transformers
 */
class RouteTransformer
{
    /**
     * RouteTransformer constructor.
     */
    public function __construct()
    {
    }

    /**
     * @param RouteCollection $routes
     * @return void
     * @throws \CatLab\Charon\Exceptions\InvalidTransformer
     */
    public function transform(RouteCollection $routes)
    {
        foreach ($routes->getRoutes() as $route) {
            $options = $route->getOptions();
            $action = $route->getAction();

            $laravelRoute = Route::match([ $route->getHttpMethod() ], $route->getPath(), $action);

            // The InputTransformer middleware makes sure that the parameters that require a
            // transformation (for example DateTimes) are transformed before the controller takes charge.
            foreach ($route->getParameters() as $parameter) {

                // Body parameter are not transformed or validated at middleware stage.
                // That's why we skip them here.
                if ($parameter->getIn() === Parameter::IN_BODY) {
                    continue;
                }

                // Now check if the parameter has an array
                if ($parameter->getTransformer()) {

                    $middleware = $this->getTransformerMiddlewareParameters(
                        $parameter->getIn(),
                        $parameter->getType(),
{'fraction_non_alphanumeric': 0.10593713620488941, 'fraction_numerical': 0.0, 'mean_word_length': 2.543298969072165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '1066376', 'n_tokens_mistral': 905, 'n_tokens_neox': 864, 'n_words': 210}