• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-warming / 16542230069

26 Jul 2025 05:32PM UTC coverage: 92.576% (+0.9%) from 91.639%
16542230069

push

github

web-flow
Merge pull request #910 from eliashaeussler/feature/typed-extconf

76 of 77 new or added lines in 8 files covered. (98.7%)

1621 of 1751 relevant lines covered (92.58%)

12.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/Classes/Mapper/ConfigurationMapperFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "warming".
7
 *
8
 * Copyright (C) 2021-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3Warming\Mapper;
25

26
use CuyZ\Valinor;
27
use EliasHaeussler\CacheWarmup;
28
use mteu\TypedExtConf;
29
use Symfony\Component\DependencyInjection;
30
use TYPO3\CMS\Core;
31

32
/**
33
 * ConfigurationMapperFactory
34
 *
35
 * @author Elias Häußler <elias@haeussler.dev>
36
 * @license GPL-2.0-or-later
37
 * @internal
38
 */
39
#[DependencyInjection\Attribute\AsAlias(TypedExtConf\Mapper\MapperFactory::class)]
40
final readonly class ConfigurationMapperFactory implements TypedExtConf\Mapper\MapperFactory
41
{
42
    public function __construct(
45✔
43
        private CacheWarmup\Crawler\Strategy\CrawlingStrategyFactory $crawlingStrategyFactory,
44
        private CacheWarmup\Config\Component\OptionsParser $optionsParser,
45
    ) {}
45✔
46

47
    public function create(): Valinor\Mapper\TreeMapper
45✔
48
    {
49
        return (new Valinor\MapperBuilder())
45✔
50
            ->allowPermissiveTypes()
45✔
51
            ->allowScalarValueCasting()
45✔
52
            ->allowUndefinedValues()
45✔
53
            ->registerConverter($this->mapOptions(...))
45✔
54
            ->registerConverter($this->mapCrawlingStrategy(...))
45✔
55
            ->registerConverter($this->mapIntegerList(...))
45✔
56
            ->registerConverter($this->mapStringList(...))
45✔
57
            ->mapper()
45✔
58
        ;
45✔
59
    }
60

61
    /**
62
     * @return array<string, mixed>
63
     * @throws CacheWarmup\Exception\OptionsAreInvalid
64
     * @throws CacheWarmup\Exception\OptionsAreMalformed
65
     */
66
    private function mapOptions(string $options): array
41✔
67
    {
68
        if ($options === '') {
41✔
69
            return [];
40✔
70
        }
71

72
        return $this->optionsParser->parse($options);
1✔
73
    }
74

75
    /**
76
     * @throws CacheWarmup\Exception\CrawlingStrategyDoesNotExist
77
     */
78
    private function mapCrawlingStrategy(string $strategy): ?CacheWarmup\Crawler\Strategy\CrawlingStrategy
41✔
79
    {
80
        if (!$this->crawlingStrategyFactory->has($strategy)) {
41✔
81
            return null;
40✔
82
        }
83

84
        return $this->crawlingStrategyFactory->get($strategy);
1✔
85
    }
86

87
    /**
88
     * @return list<int>
89
     */
90
    private function mapIntegerList(string $list): array
40✔
91
    {
92
        $list = Core\Utility\GeneralUtility::intExplode(',', $list, true);
40✔
93

94
        // @todo Remove once support for TYPO3 v12 is dropped
95
        /* @phpstan-ignore function.alreadyNarrowedType */
96
        if (!\array_is_list($list)) {
40✔
NEW
97
            $list = \array_values($list);
×
98
        }
99

100
        return $list;
40✔
101
    }
102

103
    /**
104
     * @return list<non-empty-string>
105
     */
106
    private function mapStringList(string $list): array
40✔
107
    {
108
        return Core\Utility\GeneralUtility::trimExplode(',', $list, true);
40✔
109
    }
110
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc