Passed
Push — master ( fa467c...866526 )
by Korotkov
12:11 queued 08:51
created

MainController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 23
c 3
b 0
f 2
dl 0
loc 49
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A annotations() 0 15 1
A attributes() 0 20 1
1
<?php
2
3
namespace App\Containers\Web\Controllers;
4
5
use App\Containers\Web\WebController;
6
use Rudra\EventDispatcher\EventDispatcherFacade as Dispatcher;
7
8
class MainController 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')
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(PHP_VERSION);
32
       dump(__METHOD__);
33
34
       render("layout", data());
35
    }
36
37
    #[Routing(url: '')]
38
    #[Routing(url: 'name/{name}')]
39
    #[Middleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
40
    #[Middleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
41
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
42
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
43
    public function attributes(string $name = 'John')
44
    {
45
        data([
46
            "content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']),
47
        ]);
48
49
        Dispatcher::dispatch('message', __CLASS__);
50
        $this->info("Hello $name");
51
52
        Dispatcher::notify('one');
53
        dump(PHP_VERSION);
54
        dump(__METHOD__);
55
56
        render("layout", data());
57
    }
58
}
59