Passed
Pull Request — master (#75)
by Korotkov
12:47
created

IndexController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A attributes() 0 20 1
A annotations() 0 14 1
1
<?php
2
3
namespace App\Containers\Web\Controller;
4
5
use App\Containers\Web\WebController;
6
use Rudra\EventDispatcher\EventDispatcherFacade as Dispatcher;
7
8
class IndexController extends WebController
9
{
10
    /**
11
     * @Routing(url = '')
12
     * @Routing(url = 'name/{name}')
13
     * 
14
     * @Middleware(name = 'App\Containers\Web\Middleware\FirstMiddleware')
15
     * @Middleware(name = 'App\Containers\Web\Middleware\SecondMiddleware')
16
     * 
17
     * @AfterMiddleware(name = 'App\Containers\Web\Middleware\FirstMiddleware')
18
     * @AfterMiddleware(name = 'App\Containers\Web\Middleware\SecondMiddleware')
19
     */
20
    public function annotations(string $name = 'John'): void
21
    {
22
        data([
23
            "content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']),
24
        ]);
25
26
        Dispatcher::dispatch('message', __CLASS__);
27
        $this->info("Hello $name");
28
29
        Dispatcher::notify('one');
30
31
        dump(__METHOD__);
32
33
        render("layout", data());
34
    }
35
36
    #[Routing(url: '')]
37
    #[Routing(url: 'name/:[\d]{1,3}')]
38
    #[Middleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
39
    #[Middleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
40
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
41
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
42
    public function attributes(string $name = 'John'): void
43
    {
44
        data([
45
            "content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']),
46
        ]);
47
48
        Dispatcher::dispatch('message', __CLASS__);
49
        $this->info("Hello $name");
50
51
        Dispatcher::notify('one');
52
53
        dump(__METHOD__);
54
55
        render("layout", data());
56
    }
57
}
58