Passed
Push — main ( d5b2ee...651de3 )
by Fractal
14:18
created

ClassMapper::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\ClassMapper;
6
7
use Fp\Collections\ArrayList;
8
use FRZB\Component\DependencyInjection\Attribute\AsService;
9
use FRZB\Component\RequestMapper\PropertyMapper\PropertyMapperLocatorInterface as PropertyMapperLocator;
10
11
#[AsService]
12
final class ClassMapper implements ClassMapperInterface
13
{
14
    public function __construct(
15
        private readonly PropertyMapperLocator $mapperLocator,
16
    ) {
17
    }
18
19
    public function map(string $className, mixed $value): array
20
    {
21
        try {
22
            return ArrayList::collect((new \ReflectionClass($className))->getProperties())
23
                ->map(fn (\ReflectionProperty $property) => $this->mapperLocator->get($property)->map($property, $value) ?? [])
24
                ->reduce(array_merge(...))
0 ignored issues
show
Bug introduced by
The type FRZB\Component\RequestMa...ClassMapper\array_merge was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
                ->getOrElse([])
26
            ;
27
        } catch (\ReflectionException) {
28
            return [];
29
        }
30
    }
31
}
32