ApplicationFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Http;
6
7
use Devanych\Di\FactoryInterface;
8
use HttpSoft\Basis\Application;
9
use HttpSoft\Basis\Handler\NotFoundJsonHandler;
10
use HttpSoft\Emitter\EmitterInterface;
11
use HttpSoft\Router\RouteCollector;
12
use HttpSoft\Runner\MiddlewarePipelineInterface;
13
use HttpSoft\Runner\MiddlewareResolverInterface;
14
use Psr\Container\ContainerInterface;
15
16
final class ApplicationFactory implements FactoryInterface
17
{
18
    /**
19
     * @param ContainerInterface $container
20
     * @return Application
21
     * @psalm-suppress MixedArgument
22
     * @psalm-suppress MixedArrayAccess
23
     */
24 6
    public function create(ContainerInterface $container): Application
25
    {
26 6
        return new Application(
27 6
            $container->get(RouteCollector::class),
28 6
            $container->get(EmitterInterface::class),
29 6
            $container->get(MiddlewarePipelineInterface::class),
30 6
            $container->get(MiddlewareResolverInterface::class),
31 6
            new NotFoundJsonHandler($container->get('config')['debug'])
32 6
        );
33
    }
34
}
35