Passed
Push — master ( 2505c8...c82519 )
by Dawid
08:46 queued 01:17
created

SimpleModule::provideControllers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Examples\Modules;
3
4
use Examples\Controllers\GoodbyeController;
5
use Igni\Application\Controller\ControllerAggregate;
6
use Igni\Application\Providers\ControllerProvider;
7
use Igni\Http\Response;
8
use Igni\Http\Route;
9
10
/**
11
 * Module definition.
12
 */
13
class SimpleModule implements ControllerProvider
14
{
15
    /**
16
     * @param \Igni\Http\Controller\ControllerAggregate $controllers
17
     */
18
    public function provideControllers(ControllerAggregate $controllers): void
19
    {
20
        $controllers->add(function ($request) {
21
            return Response::fromText("Hello {$request->getAttribute('name')}!");
22
        }, Route::get('/hello/{name}'));
23
24
        $controllers->add(GoodbyeController::class);
25
    }
26
}
27