ShipController::shipInit()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 2
eloc 6
c 3
b 1
f 0
nc 2
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
namespace App\Ship;
4
5
use Rudra\Controller\Controller;
6
use Rudra\Container\Facades\Rudra;
7
use App\Containers\Demo\Observer\TestObserver;
8
use Rudra\Controller\ShipControllerInterface;
9
use App\Containers\Demo\Listener\MessageListener;
10
use Rudra\EventDispatcher\EventDispatcherFacade as Dispatcher;
11
12
/**
13
 * In summary, this code is responsible for initializing a ship and registering events.
14
 * ------------------------------------------------------------------------------------
15
 * В целом, этот код предназначен для инициализации корабля и регистрации событий.
16
 */
17
class ShipController extends Controller implements ShipControllerInterface
18
{
19
    public function shipInit(): void
20
    {
21
        if (Rudra::config()->get("environment") === "development") {
22
            
23
            Rudra::get("debugbar")['time']->stopMeasure('routing');
24
            Rudra::get("debugbar")['time']->stopMeasure('application');
25
26
            data([
27
                "debugbar" => Rudra::get("debugbar")->getJavascriptRenderer(),
28
            ]);
29
        }
30
31
        $this->eventRegistration();
32
    }
33
34
    public function eventRegistration(): void
35
    {
36
        Dispatcher::addListener('message', [MessageListener::class, 'info']);
37
        Dispatcher::attachObserver('one', [TestObserver::class, 'onEvent'], __CLASS__);
38
    }
39
}
40