Test Failed
Push — main ( 8bbfd5...5b42e4 )
by Fractal
03:27
created

ArrayAsAttributePropertyMapper::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\PropertyMapper\Mapper;
6
7
use FRZB\Component\DependencyInjection\Attribute\AsService;
8
use FRZB\Component\DependencyInjection\Attribute\AsTagged;
9
use FRZB\Component\RequestMapper\Helper\ConstraintsHelper;
10
use FRZB\Component\RequestMapper\Helper\PropertyHelper;
11
12
#[AsService, AsTagged(PropertyMapperInterface::class, priority: 3)]
13
final class ArrayAsAttributePropertyMapper implements PropertyMapperInterface
14
{
15
    public function map(\ReflectionProperty $property, mixed $value): array
16
    {
17
        return [
18
            PropertyHelper::getName($property) => array_map(static fn () => PropertyHelper::getTypeFromAttribute($property), range(0, \count($value))),
19
        ];
20
    }
21
22
    public function canMap(\ReflectionProperty $property): bool
23
    {
24
        return ConstraintsHelper::hasArrayTypeAttribute($property);
25
    }
26
}
27