Passed
Push — master ( c53f0c...529f2b )
by Rustam
02:38
created

WrapperFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\RequestModel;
6
7
use Psr\Container\ContainerInterface;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Yiisoft\Middleware\Dispatcher\WrapperFactoryInterface;
10
11
final class WrapperFactory implements WrapperFactoryInterface
12
{
13 2
    public function __construct(
14
        private ContainerInterface $container,
15
        private HandlerParametersResolver $parametersResolver
16
    ) {
17
    }
18
19
    /**
20
     * {@inheritDoc}
21
     */
22 2
    public function create($callable): MiddlewareInterface
23
    {
24 2
        if (is_array($callable)) {
25 1
            return new ActionWrapper($this->container, $this->parametersResolver, $callable[0], $callable[1]);
26
        }
27 1
        return new CallableWrapper($this->container, $this->parametersResolver, $callable);
28
    }
29
}
30