Passed
Push — master ( d1c5a6...bac8bf )
by Fabian
03:36 queued 12s
created

AsseticMiddlewareFactory::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 9
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\AsseticBundle\Factory;
6
7
use Laminas\ServiceManager\Factory\FactoryInterface;
8
use Interop\Container\ContainerInterface;
9
use Fabiang\AsseticBundle\AsseticMiddleware;
10
use Fabiang\AsseticBundle\Service as AsseticService;
11
use Laminas\View\Renderer\PhpRenderer;
12
13
final class AsseticMiddlewareFactory implements FactoryInterface
14
{
15
16
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): object
17
    {
18
        /** @var AsseticService $asseticService */
19
        $asseticService = $container->get(AsseticService::class);
20
21
        // Create or retrieve the renderer from the container
22
        $viewRenderer = ($container->has(PhpRenderer::class)) ? $container->get(PhpRenderer::class) : new PhpRenderer();
23
24
        return new AsseticMiddleware($asseticService, $viewRenderer);
25
    }
26
27
}
28