MethodValidator.php
TLDR
This file contains the code for the MethodValidator
class, which is responsible for validating a route against a request method.
Classes
MethodValidator
The MethodValidator
class implements the ValidatorInterface
and is used to validate a given rule against a route and request. It has one method:
matches(Route $route, Request $request)
This method checks if the request method matches any of the methods specified by the route. It returns true
if there is a match, and false
otherwise.
<?php
namespace Illuminate\Routing\Matching;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
class MethodValidator implements ValidatorInterface
{
/**
* Validate a given rule against a route and request.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function matches(Route $route, Request $request)
{
return in_array($request->getMethod(), $route->methods());
}
}