for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace FRZB\Component\RequestMapper\Mapper;
use Fp\Collections\ArrayList;
use FRZB\Component\DependencyInjection\Attribute\AsService;
use FRZB\Component\RequestMapper\Mapper\MapperInterface as TypeMapper;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
#[AsService]
class MapperLocator implements MapperLocatorInterface
{
/** @var ArrayList<string, callable|TypeMapper> */
private readonly ArrayList $mappers;
public function __construct(
#[TaggedIterator(TypeMapper::class, defaultPriorityMethod: 'getPriority')]
iterable $mappers,
) {
$this->mappers = ArrayList::collect($mappers);
mappers
FRZB\Component\RequestMapper\Mapper\MapperLocator
}
public function get(string $typeName, mixed $value = null): MapperInterface
return $this->mappers
->first(static fn (TypeMapper $tm) => $tm->canMap($typeName, $value))
->get()
;