Completed
Pull Request — master (#10)
by Korotkov
01:35
created

Route::getToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Http;
4
5
use Rudra\Router;
6
7
class Route
8
{
9
10
    protected $token;
11
12
    public function __construct(Router $router, string $namespace)
13
    {
14
        $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...
15
        
16
        $router->annotation('MainController');              // mainpage
17
18
        $router->middleware('get', [
19
                'pattern'     => '123/123',
20
                'controller'  => 'MainController',
21
                'method'      => 'actionIndex',
22
                'middleware'  => [
23
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 1]],
24
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 2]],
25
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 3]],
26
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 4]]
27
                ],
28
29
                'after_middleware'  => [
30
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 5]],
31
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 6]],
32
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 7]],
33
                    ['\\App\\Http\\Middleware\\MainMiddleware::namespace', ['int' => 8]]
34
                ]
35
            ]
36
        );
37
38
        $router->middleware('get', [
39
            'pattern'     => '123/122',
40
            'controller'  => 'MainController',
41
            'method'      => 'actionIndex',
42
            'middleware'  => [
43
                ['MainMiddleware', ['int' => 1]],
44
                ['MainMiddleware', ['int' => 2]],
45
                ['MainMiddleware', ['int' => 3]],
46
                ['MainMiddleware', ['int' => 4]]
47
            ],
48
49
            'after_middleware'  => [
50
                ['MainMiddleware', ['int' => 5]],
51
                ['MainMiddleware', ['int' => 6]],
52
                ['MainMiddleware', ['int' => 7]],
53
                ['MainMiddleware', ['int' => 8]]
54
            ]
55
        ]);
56
57
        $this->token = $router->isToken();
58
    }
59
60
    public function getToken()
61
    {
62
        return $this->token;
63
    }
64
}
65