Passed
Branch master (f6b1e4)
by Jean-Bernard
02:29 queued 01:01
created

ReRouteControllerModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
ccs 0
cts 5
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
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));
0 ignored issues
show
Bug introduced by
The method reRoute() does not seem to exist on object<SymfonyUtil\Compo...ReRouteControllerModel>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
    }
46
}
47
48
// Inspired from https://github.com/symfony/symfony/blob/v3.3.8/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
49