for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fyuze\Routing;
use Fyuze\Http\Exception\NotFoundException;
use Psr\Http\Message\ServerRequestInterface;
class Router
{
/**
* @var Collection
*/
protected $routes;
* @param Collection $routes
public function __construct(Collection $routes)
$this->routes = $routes;
}
* @param ServerRequestInterface $request
* @return Route
* @throws NotFoundException
public function resolve(ServerRequestInterface $request)
$route = $this->match($request);
if (count($route) === 0) {
throw new NotFoundException('Page not found');
return reset($route);
* @return array
protected function match(ServerRequestInterface $request)
return array_filter($this->routes->getRoutes(), function (Route $route) use ($request) {
$match = $route->matches($request);
if(false !== $match) {
return $route->setParams($match);
$match
true
array
$params
Fyuze\Routing\Route::setParams()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
return $route->setParams(/** @scrutinizer ignore-type */ $match);
});