RequestUriParametersResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromArray() 0 7 3
1
<?php
2
3
namespace CHStudio\Raven\Http\Factory;
4
5
use CHStudio\Raven\Http\Factory\Resolver\ValueResolverInterface;
6
use Psr\Http\Message\RequestInterface;
7
8
class RequestUriParametersResolver implements RequestFactoryInterface
9
{
10 3
    public function __construct(
11
        private readonly ValueResolverInterface $resolver,
12
        private readonly RequestFactoryInterface $decorated
13
    ) {
14 3
    }
15
16
    /**
17
     * @param array<string, mixed> $data
18
     */
19 2
    public function fromArray(array $data): RequestInterface
20
    {
21 2
        if (isset($data['uri']) && \is_array($data['uri'])) {
22 1
            $data['uri']['parameters'] = $this->resolver->resolve($data['uri']['parameters'] ?? []);
23
        }
24
25 2
        return $this->decorated->fromArray($data);
26
    }
27
}
28