BuiltinPropertyMapper::canMap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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\PropertyHelper;
10
use FRZB\Component\RequestMapper\TypeExtractor\TypeExtractorLocatorInterface;
11
12
#[AsService, AsTagged(PropertyMapperInterface::class, priority: 1)]
13
class BuiltinPropertyMapper implements PropertyMapperInterface
14
{
15
    public function __construct(
16
        private readonly TypeExtractorLocatorInterface $extractorLocator,
17
    ) {
18
    }
19
20
    public function map(\ReflectionProperty $property, mixed $value): array
21
    {
22
        return [PropertyHelper::getName($property) => PropertyHelper::getTypeName($property)];
23
    }
24
25
    public function canMap(\ReflectionProperty $property): bool
26
    {
27
        return !$this->extractorLocator->has($property);
28
    }
29
}
30