Completed
Push — master ( a2928f...fb62f0 )
by Jean-Bernard
01:57
created

ReRouteControllerModel.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SymfonyUtil\Component\HttpFoundation;
13
14
// Similar namespace in Symfony
15
// https://github.com/symfony/symfony/tree/v3.3.8/src/Symfony/Component/Routing/Generator
16
17
use Symfony\Component\HttpFoundation\Request;
18
19
// use SymfonyUtil\Component\HttpFoundation\ReRouteControllerModelInterface;
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
20
// use SymfonyUtil\Component\HttpFoundation\ReRouteInterface;
21
// use SymfonyUtil\Component\HttpFoundation\ResponseParameters;
22
23
class ReRouteControllerModel implements ReRouteControllerModelInterface
24
{
25
    protected $reRoute;
26
27
    public function __construct(ReRouteInterface $reRoute)
28
    {
29
        $this->reRoute = $reRoute;
30
    }
31
32
    /**
33
     * Returns ResponseParameters to the given route with the given parameters.
34
     *
35
     * @param string $route      The name of the route
36
     * @param mixed  $parameters An array of parameters
37
     *
38
     * @return Response
39
     *
40
     * @see Interface ReRouteControllerModelInterface
41
     */
42
    public function __invoke($route, $parameters = [], Request $request = null)
43
    {
44
        return new ResponseParameters([], $this->reRoute($route, $parameters));
45
    }
46
}
47
48
// Inspired from https://github.com/symfony/symfony/blob/v3.3.8/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
49