Test Failed
Push — main ( 450f80...a11e57 )
by Fractal
02:32
created

ArrayAsAttributePropertyMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canMap() 0 3 1
A map() 0 4 1
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