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

WrapperFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 17
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 6 2
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