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

api-platform / core / 20847864477

09 Jan 2026 09:47AM UTC coverage: 29.1% (+0.005%) from 29.095%
20847864477

Pull #7649

github

web-flow
Merge b342dd5db into d640d106b
Pull Request #7649: feat(validator): uuid/ulid parameter validation

0 of 4 new or added lines in 1 file covered. (0.0%)

15050 existing lines in 491 files now uncovered.

16996 of 58406 relevant lines covered (29.1%)

81.8 hits per line

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

100.0
/src/Symfony/Maker/MakeFilter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\Maker;
15

16
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
17
use ApiPlatform\Symfony\Maker\Enum\SupportedFilterTypes;
18
use Symfony\Bundle\MakerBundle\ConsoleStyle;
19
use Symfony\Bundle\MakerBundle\DependencyBuilder;
20
use Symfony\Bundle\MakerBundle\Generator;
21
use Symfony\Bundle\MakerBundle\InputConfiguration;
22
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
23
use Symfony\Component\Console\Command\Command;
24
use Symfony\Component\Console\Input\InputArgument;
25
use Symfony\Component\Console\Input\InputInterface;
26
use Symfony\Component\Console\Input\InputOption;
27

28
final class MakeFilter extends AbstractMaker
29
{
30
    public function __construct(private readonly string $namespacePrefix = '')
31
    {
UNCOV
32
    }
18✔
33

34
    /**
35
     * {@inheritdoc}
36
     */
37
    public static function getCommandName(): string
38
    {
UNCOV
39
        return 'make:filter';
12✔
40
    }
41

42
    /**
43
     * {@inheritdoc}
44
     */
45
    public static function getCommandDescription(): string
46
    {
UNCOV
47
        return 'Creates an API Platform filter';
12✔
48
    }
49

50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function configureCommand(Command $command, InputConfiguration $inputConfig): void
54
    {
UNCOV
55
        $command
18✔
UNCOV
56
            ->addArgument('type', InputArgument::REQUIRED, \sprintf('Choose a type for your filter (<fg=yellow>%s</>)', self::getFilterTypesAsString()))
18✔
UNCOV
57
            ->addArgument('name', InputArgument::REQUIRED, 'Choose a class name for your filter (e.g. <fg=yellow>AwesomeFilter</>)')
18✔
UNCOV
58
            ->addOption('namespace-prefix', 'p', InputOption::VALUE_REQUIRED, 'Specify the namespace prefix to use for the filter class', $this->namespacePrefix.'Filter')
18✔
UNCOV
59
            ->setHelp(file_get_contents(__DIR__.'/Resources/help/MakeFilter.txt'));
18✔
60
    }
61

62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function configureDependencies(DependencyBuilder $dependencies): void
66
    {
UNCOV
67
    }
18✔
68

69
    /**
70
     * {@inheritdoc}
71
     *
72
     * @throws \Exception
73
     */
74
    public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
75
    {
UNCOV
76
        $typeArgument = strtolower((string) $input->getArgument('type'));
14✔
UNCOV
77
        $type = SupportedFilterTypes::tryFrom($typeArgument);
14✔
UNCOV
78
        if (null === $type) {
14✔
UNCOV
79
            throw new InvalidArgumentException(\sprintf('The type "%s" is not a valid filter type, valid options are: %s.', $typeArgument, self::getFilterTypesAsString()));
4✔
80
        }
81

UNCOV
82
        $filterNameDetails = $generator->createClassNameDetails(
10✔
UNCOV
83
            name: $input->getArgument('name'),
10✔
UNCOV
84
            namespacePrefix: trim($input->getOption('namespace-prefix'), '\\').'\\'
10✔
UNCOV
85
        );
10✔
UNCOV
86
        $filterName = \sprintf('%sFilter', ucfirst($type->value));
10✔
87

UNCOV
88
        $generator->generateClass(className: $filterNameDetails->getFullName(), templateName: \sprintf(
10✔
UNCOV
89
            '%s/Resources/skeleton/%s.php.tpl',
10✔
UNCOV
90
            __DIR__,
10✔
UNCOV
91
            $filterName
10✔
UNCOV
92
        ));
10✔
93

UNCOV
94
        $generator->writeChanges();
10✔
95

UNCOV
96
        $this->writeSuccessMessage($io);
10✔
UNCOV
97
        $io->text([
10✔
UNCOV
98
            'Next: Open your filter class and start customizing it.',
10✔
UNCOV
99
        ]);
10✔
100
    }
101

102
    private static function getFilterTypesAsString(): string
103
    {
UNCOV
104
        $validOptions = array_column(SupportedFilterTypes::cases(), 'value');
18✔
105

UNCOV
106
        return implode(' or ', array_map('strtoupper', $validOptions));
18✔
107
    }
108
}
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