<commit_before><?php

/**
 * This file is part of the Arachne
 *
 * Copyright (c) <NAME> (<EMAIL>)
 *
 * For the full copyright and license information, please view the file license.md that was distributed with this source code.
 */

namespace Arachne\EntityLoader\Application;

use Nette\Application\Routers\Route as BaseRoute;
use Nette\InvalidArgumentException;

/**
 * @author <NAME> <<EMAIL>>
 */
class Route extends BaseRoute
{

	/**
	 * {@inheritdoc}
	 */
	public function __construct($mask, $metadata = [], $flags = 0)
	{
		// Copied from Nette\Application\Routers\Route::__construct()
		if (is_string($metadata)) {
			$pos = strrpos($metadata, ':');
			if (!$pos) {
				throw new InvalidArgumentException("Second argument must be array or string in format Presenter:action, '$metadata' given.");
			}
			$metadata = [
				self::PRESENTER_KEY => substr($metadata, 0, $pos),
				'action' => $a === strlen($metadata) - 1 ? NULL : substr($metadata, $pos + 1),
			];
		} elseif ($metadata instanceof \Closure || $metadata instanceof Nette\Callback) {
			$metadata = array(
				self::PRESENTER_KEY => 'Nette:Micro',
				'callback' => $metadata,
			);
		}

		// Filter for handling Envelopes correctly
		$filter = function (array $parameters) use ($metadata) {
			foreach ($parameters as $key => & $value) {
				if ($value instanceof Envelope && !isset($metadata[$key][self::FILTER_OUT])) {
					$value = $value->getIdentifier();
				}
			}
			return $parameters;
		};

		// Hack to invoke the filter after custom global filter
		if (isset($metadata[NULL][self::FILTER_OUT])) {
			$custom = $metadata[NULL][self::FILTER_OUT];
			$metadata[NULL][self::FILTER_OUT] = function (array $parameters) use ($custom, $filter) {
				$parameters = call_user_func($custom, $parameters);
				if (!is_array($parameters)) {
					return $parameters;
				}
				return call_user_func($filter, $parameters);
			};
		} else {
			$metadata[NULL][self::FILTER_OUT] = $filter;
		}

		parent::__construct($mask, $metadata, $flags);
	}

}
<commit_msg>Fixed variable name<commit_after><?php

/**
 * This file is part of the Arachne
 *
 * Copyright (c) <NAME> (<EMAIL>)
 *
 * For the full copyright and license information, please view the file license.md that was distributed with this source code.
 */

namespace Arachne\EntityLoader\Application;

use Nette\Application\Routers\Route as BaseRoute;
use Nette\InvalidArgumentException;

/**
 * @author <NAME> <<EMAIL>>
 */
class Route extends BaseRoute
{

	/**
	 * {@inheritdoc}
	 */
	public function __construct($mask, $metadata = [], $flags = 0)
	{
		// Copied from Nette\Application\Routers\Route::__construct()
		if (is_string($metadata)) {
			$pos = strrpos($metadata, ':');
			if (!$pos) {
				throw new InvalidArgumentException("Second argument must be array or string in format Presenter:action, '$metadata' given.");
			}
			$metadata = [
				self::PRESENTER_KEY => substr($metadata, 0, $pos),
				'action' => $pos === strlen($metadata) - 1 ? NULL : substr($metadata, $pos + 1),
			];
		} elseif ($metadata instanceof \Closure || $metadata instanceof Nette\Callback) {
			$metadata = array(
				self::PRESENTER_KEY => 'Nette:Micro',
				'callback' => $metadata,
			);
		}

		// Filter for handling Envelopes correctly
		$filter = function (array $parameters) use ($metadata) {
			foreach ($parameters as $key => & $value) {
				if ($value instanceof Envelope && !isset($metadata[$key][self::FILTER_OUT])) {
					$value = $value->getIdentifier();
				}
			}
			return $parameters;
		};

		// Hack to invoke the filter after custom global filter
		if (isset($metadata[NULL][self::FILTER_OUT])) {
			$custom = $metadata[NULL][self::FILTER_OUT];
			$metadata[NULL][self::FILTER_OUT] = function (array $parameters) use ($custom, $filter) {
				$parameters = call_user_func($custom, $parameters);
				if (!is_array($parameters)) {
					return $parameters;
				}
				return call_user_func($filter, $parameters);
			};
		} else {
			$metadata[NULL][self::FILTER_OUT] = $filter;
		}

		parent::__construct($mask, $metadata, $flags);
	}

}

{'fraction_non_alphanumeric': 0.15846456692913385, 'fraction_numerical': 0.001968503937007874, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '4707327', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1234, 'n_words': 328}