Completed
Push — master ( f661f8...96e4bc )
by Alexey
02:47 queued 12s
created

ConstructRequestObjectValueResolver::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nelexa\RequestDtoBundle\ArgumentResolver;
6
7
use Nelexa\RequestDtoBundle\Dto\ConstructRequestObjectInterface;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
10
11
class ConstructRequestObjectValueResolver extends AbstractObjectValueResolver
12
{
13 25
    public function supports(Request $request, ArgumentMetadata $argument): bool
14
    {
15 25
        return is_a($argument->getType(), ConstructRequestObjectInterface::class, true);
16
    }
17
18 4
    protected function serialize(Request $request, ArgumentMetadata $argument, string $format): object
19
    {
20 4
        $type = $argument->getType();
21
22 4
        return new $type($request);
23
    }
24
}
25