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

api-platform / core / 18089958695

29 Sep 2025 07:57AM UTC coverage: 21.569% (-0.2%) from 21.797%
18089958695

push

github

web-flow
fix(openapi): define items type for HydraCollectionBaseSchema hydra:member (#7419)

Co-authored-by: Thibaut Cholley <thibaut.cholley@elsie-sante.fr>

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

12063 existing lines in 401 files now uncovered.

11765 of 54545 relevant lines covered (21.57%)

12.57 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

27
final class MakeFilter extends AbstractMaker
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public static function getCommandName(): string
33
    {
UNCOV
34
        return 'make:filter';
2✔
35
    }
36

37
    /**
38
     * {@inheritdoc}
39
     */
40
    public static function getCommandDescription(): string
41
    {
UNCOV
42
        return 'Creates an API Platform filter';
2✔
43
    }
44

45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function configureCommand(Command $command, InputConfiguration $inputConfig): void
49
    {
UNCOV
50
        $command
8✔
UNCOV
51
            ->addArgument('type', InputArgument::REQUIRED, \sprintf('Choose a type for your filter (<fg=yellow>%s</>)', self::getFilterTypesAsString()))
8✔
UNCOV
52
            ->addArgument('name', InputArgument::REQUIRED, 'Choose a class name for your filter (e.g. <fg=yellow>AwesomeFilter</>)')
8✔
UNCOV
53
            ->setHelp(file_get_contents(__DIR__.'/Resources/help/MakeFilter.txt'));
8✔
54
    }
55

56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function configureDependencies(DependencyBuilder $dependencies): void
60
    {
UNCOV
61
    }
8✔
62

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

UNCOV
76
        $filterNameDetails = $generator->createClassNameDetails(
4✔
UNCOV
77
            name: $input->getArgument('name'),
4✔
UNCOV
78
            namespacePrefix: 'Filter\\'
4✔
UNCOV
79
        );
4✔
UNCOV
80
        $filterName = \sprintf('%sFilter', ucfirst($type->value));
4✔
81

UNCOV
82
        $generator->generateClass(className: $filterNameDetails->getFullName(), templateName: \sprintf(
4✔
UNCOV
83
            '%s/Resources/skeleton/%s.php.tpl',
4✔
UNCOV
84
            __DIR__,
4✔
UNCOV
85
            $filterName
4✔
UNCOV
86
        ));
4✔
87

UNCOV
88
        $generator->writeChanges();
4✔
89

UNCOV
90
        $this->writeSuccessMessage($io);
4✔
UNCOV
91
        $io->text([
4✔
UNCOV
92
            'Next: Open your filter class and start customizing it.',
4✔
UNCOV
93
        ]);
4✔
94
    }
95

96
    private static function getFilterTypesAsString(): string
97
    {
UNCOV
98
        $validOptions = array_column(SupportedFilterTypes::cases(), 'value');
8✔
99

UNCOV
100
        return implode(' or ', array_map('strtoupper', $validOptions));
8✔
101
    }
102
}
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