Completed
Push — master ( 3bb683...8cf661 )
by Korotkov
01:35
created

Route   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 93.33 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 42
loc 45
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 42 42 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Web;
4
5
use Rudra\Router;
6
7
class Route
8
{
9 View Code Duplication
    public function run(Router $router, $namespace)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        $router->setNamespace($namespace);
0 ignored issues
show
Bug introduced by
The method setNamespace() does not seem to exist on object<Rudra\Router>.

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...
12
        $router->annotation('MainController');              // mainpage
13
        $router->middleware('get', [
14
                'pattern'     => '123/123',
15
                'controller'  => 'MainController',
16
                'method'      => 'actionIndex',
17
                'middleware'  => [
18
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 1]],
19
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 2]],
20
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 3]],
21
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 4]]
22
                ],
23
                'after_middleware'  => [
24
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 5]],
25
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 6]],
26
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 7]],
27
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 8]]
28
                ]
29
            ]
30
        );
31
        $router->middleware('get', [
32
            'pattern'     => '123/122',
33
            'controller'  => 'MainController',
34
            'method'      => 'actionIndex',
35
            'middleware'  => [
36
                ['MainMiddleware', ['int' => 1]],
37
                ['MainMiddleware', ['int' => 2]],
38
                ['MainMiddleware', ['int' => 3]],
39
                ['MainMiddleware', ['int' => 4]]
40
            ],
41
            'after_middleware'  => [
42
                ['MainMiddleware', ['int' => 5]],
43
                ['MainMiddleware', ['int' => 6]],
44
                ['MainMiddleware', ['int' => 7]],
45
                ['MainMiddleware', ['int' => 8]]
46
            ]
47
        ]);
48
49
        return $router->isToken();
50
    }
51
}
52