Passed
Push — master ( c3e433...2d63f5 )
by Korotkov
03:15 queued 01:37
created

IndexController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Containers\Web\Controller;
4
5
use stdClass;
6
use App\Containers\Web\WebController;
7
use App\Containers\Web\Factory\StdFactory;
8
use Rudra\Container\Interfaces\RudraInterface;
9
use App\Containers\Web\Interface\TestInterface;
10
use Rudra\Container\Facades\Rudra;
11
use Rudra\EventDispatcher\EventDispatcherFacade as Dispatcher;
12
13
class IndexController extends WebController
14
{
15
    public function __construct(stdClass $std)
16
    {
17
        $std->name = __METHOD__ . '::Dependency Injection';
18
        dump($std);
19
    }
20
21
    /**
22
     * @Routing(url = '')
23
     * @Routing(url = 'name/{name}')
24
     * 
25
     * @Middleware(name = 'App\Containers\Web\Middleware\FirstMiddleware')
26
     * @Middleware(name = 'App\Containers\Web\Middleware\SecondMiddleware')
27
     * 
28
     * @AfterMiddleware(name = 'App\Containers\Web\Middleware\FirstMiddleware')
29
     * @AfterMiddleware(name = 'App\Containers\Web\Middleware\SecondMiddleware')
30
     */
31
    public function annotations(string $name = 'John'): void
32
    {
33
        data([
34
            "content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']),
35
        ]);
36
37
        Dispatcher::dispatch('message', __CLASS__);
38
        $this->info("Hello $name");
39
40
        Dispatcher::notify('one');
41
42
        dump(__METHOD__);
43
44
        render("layout", data());
45
    }
46
47
    #[Routing(url: '')]
48
    #[Routing(url: 'name/:[\d]{1,3}')]
49
    #[Middleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
50
    #[Middleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
51
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')]
52
    #[AfterMiddleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')]
53
    public function attributes(stdClass $std, string $name = 'John'): void
54
    {
55
        data([
56
            "content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']),
57
        ]);
58
59
        Dispatcher::dispatch('message', __CLASS__);
60
        $this->info("Hello $name");
61
        Dispatcher::notify('one');
62
63
        dump($std);
64
        dump(Rudra::get('factory'));
65
        dump(Rudra::get('callable'));
66
67
        render("layout", data());
68
    }
69
70
    #[Routing(url: 'autowire')]
71
    public function autowire(RudraInterface $rudra, stdClass $std, TestInterface $test, StdFactory $factory): void
72
    {
73
        dd($rudra, $std, $test, $factory);
74
    }
75
}
76