<commit_before><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Rest;

use Everon\Config\Interfaces\ItemRouter;
use Everon\Interfaces\Request;
use Everon\Exception;
use Everon\Router as EveronRouter;

class Router extends EveronRouter implements Interfaces\Router
{
    /**
     * @inheritdoc
     */
    public function getRouteByRequest(Request $Request)
    {
        try {
            $DefaultItem = parent::getRouteByRequest($Request);
        }
        catch (\Exception $e) {
            $DefaultItem = null;
        }

        if ($DefaultItem !== null) {
            return $DefaultItem;
        }
        
        foreach ($this->getConfig()->getItems() as $RouteItem) {
            /**
             * @var ItemRouter $RouteItem
             */
            if ($RouteItem->matchesByPath($Request->getPath())) {
                if ($Request->getMethod() === $RouteItem->getMethod()) {
                    $this->validateAndUpdateRequestAndRouteItem($RouteItem, $Request);
                    return $RouteItem;
                }
            }
        }<commit_msg>added check for HTTP method when matching default route Item<commit_after><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Rest;

use Everon\Config\Interfaces\ItemRouter;
use Everon\Interfaces\Request;
use Everon\Exception;
use Everon\Router as EveronRouter;

class Router extends EveronRouter implements Interfaces\Router
{
    /**
     * @inheritdoc
     */
    public function getRouteByRequest(Request $Request)
    {
        try {
            $DefaultItem = parent::getRouteByRequest($Request);
        }
        catch (\Exception $e) {
            $DefaultItem = null;
        }

        if ($DefaultItem !== null && $Request->getMethod() === $DefaultItem->getMethod()) {
            return $DefaultItem;
        }
        
        foreach ($this->getConfig()->getItems() as $RouteItem) {
            /**
             * @var ItemRouter $RouteItem
             */
            if ($RouteItem->matchesByPath($Request->getPath())) {
                if ($Request->getMethod() === $RouteItem->getMethod()) {
                    $this->validateAndUpdateRequestAndRouteItem($RouteItem, $Request);
                    return $RouteItem;
                }
            }
        }
{'fraction_non_alphanumeric': 0.11726508785332315, 'fraction_numerical': 0.0, 'mean_word_length': 2.103080568720379, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5971867', 'n_tokens_mistral': 688, 'n_tokens_neox': 678, 'n_words': 177}