<commit_before><?php

namespace NickStuer\EasyRouter;

class RouteManager
{
    /**
     * @var array
     */
    private $routes = array();

    /**
     * @var string
     */
    private $allowedMethods = array('get', 'post');

    /**
     * RouteManager constructor.
     *
     * @param string $routePath
     */
    public function __construct($routePath = '')
    {
        if ($routePath !== '') {
            $this->loadRoutes($routePath);
        }
    }

    /**
     * Returns the collected array of Routes.
     *
     * @return array
     */
    public function getRoutes()
    {
        return $this->routes;
    }

    /**
     * Load the routes from a file instead of the running application.
     *
     * @param string $routesFilePath
     */
    private function loadRoutes($routesFilePath)
    {
        $routes = require __DIR__ . '/' . $routesFilePath;

        foreach ($routes as $route) {
            $this->addRoute($route[0], $route[1], $route[2]);
        }
    }

    /**
     * Add a route to the route array.
     *
     * @param string $httpMethod
     *
     * @param string $path
     *
     * @param string $action
     *
     * @throws Exceptions\RouteInvalidException
     */
    public function addRoute($httpMethod, $path, $action)
    {
        if (!in_array($httpMethod, $this->allowedMethods)) {
            throw new Exceptions\RouteInvalidException('Method Not Allowed');
        }

        $this->routes[] = new Route($httpMethod, $path, $action);
    }
}<commit_msg>removed creating new Route class from inside RouteManager<commit_after><?php

namespace NickStuer\EasyRouter;

class RouteManager
{
    /**
     * @var array
     */
    private $routes = array();

    /**
     * @var string
     */
    private $allowedMethods = array('get', 'post');

    /**
     * RouteManager constructor.
     *
     * @param string $routePath
     */
    public function __construct($routePath = '')
    {
        if ($routePath !== '') {
            $this->loadRoutes($routePath);
        }
    }

    /**
     * Returns the collected array of Routes.
     *
     * @return array
     */
    public function getRoutes()
    {
        return $this->routes;
    }

    /**
     * Load the routes from a file instead of the running application.
     *
     * @param string $routesFilePath
     */
    private function loadRoutes($routesFilePath)
    {
        $routes = require __DIR__ . '/' . $routesFilePath;

        foreach ($routes as $route) {
            $this->addRoute($route[0], $route[1], $route[2]);
        }
    }

    /**
     * Add a route to the route array.
     *
     * @param Route $route
     */
    public function addRoute(Route $route)
    {
        $this->routes[] = $route;
    }
}
{'fraction_non_alphanumeric': 0.13420860685630925, 'fraction_numerical': 0.002188183807439825, 'mean_word_length': 1.8873684210526316, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4361414', 'n_tokens_mistral': 804, 'n_tokens_neox': 806, 'n_words': 195}