Conditions | 1 |
Paths | 1 |
Total Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
23 | final public static function collections( |
||
24 | RouteCollection $route, |
||
25 | Container $container |
||
26 | ) { |
||
27 | /** |
||
28 | * Content-Type: application/json |
||
29 | */ |
||
30 | $route->group('', function (RouteGroup $route) use ($container) { |
||
31 | $route->map( |
||
32 | 'GET', |
||
33 | '/', |
||
34 | function (ServerRequestInterface $request, Response $response) { |
||
35 | return $response->withArray(['Hello' => 'World']); |
||
36 | } |
||
37 | ); |
||
38 | |||
39 | $route->map( |
||
40 | 'GET', |
||
41 | '/hello/{name}', |
||
42 | [ |
||
43 | new HelloWorld( |
||
44 | $container->addServiceProvider(new \PhpBootstrap\ServiceProviders\Controller\HelloWorld) |
||
45 | ), |
||
46 | 'sayHi' |
||
47 | ] |
||
48 | )->middleware(new DummyTokenChecker()); |
||
49 | |||
50 | })->middleware(new applicationJSON()); |
||
51 | |||
52 | /** |
||
53 | * Content-Type: text/html |
||
54 | */ |
||
55 | $route->group('', function (RouteGroup $route) use ($container) { |
||
56 | |||
57 | $route->map( |
||
58 | 'GET', |
||
59 | '/html', |
||
60 | function (ServerRequestInterface $request, Response $response) { |
||
61 | $response->getBody()->write('<h1>Home Page!</h1>'); |
||
62 | return $response->withStatus(200); |
||
63 | } |
||
64 | ); |
||
65 | |||
66 | })->middleware(new textHTML()); |
||
67 | } |
||
68 | } |