Issues (105)

src/AutoMapper/RestAutoMapperConfiguration.php (1 issue)

1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/AutoMapper/RestAutoMapperConfiguration.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\AutoMapper;
10
11
use AutoMapperPlus\AutoMapperPlusBundle\AutoMapperConfiguratorInterface;
12
use AutoMapperPlus\Configuration\AutoMapperConfigInterface;
13
use AutoMapperPlus\MapperInterface;
14
use Symfony\Component\HttpFoundation\Request;
15
16
/**
17
 * Class RestAutoMapperConfiguration
18
 *
19
 * @package App\AutoMapper
20
 * @author TLe, Tarmo Leppänen <[email protected]>
21
 */
22
abstract class RestAutoMapperConfiguration implements AutoMapperConfiguratorInterface
23
{
24
    /**
25
     * Classes to use specified request mapper.
26
     *
27
     * @var array<int, class-string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<int, class-string> at position 4 could not be parsed: Unknown type name 'class-string' at position 4 in array<int, class-string>.
Loading history...
28
     */
29
    protected static array $requestMapperClasses = [];
30
31 82
    public function __construct(
32
        protected readonly MapperInterface $requestMapper,
33
    ) {
34 82
    }
35
36
    /**
37
     * Use this method to register your mappings.
38
     *
39
     * @psalm-suppress UndefinedThisPropertyFetch
40
     */
41 79
    public function configure(AutoMapperConfigInterface $config): void
42
    {
43 79
        foreach (static::$requestMapperClasses as $requestMapperClass) {
44 79
            $config
45 79
                ->registerMapping(Request::class, $requestMapperClass)
46 79
                ->useCustomMapper($this->requestMapper);
47
        }
48
    }
49
}
50