RequestUriParametersResolver::fromArray()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 3
nc 2
nop 1
crap 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