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

api-platform / core / 18118664137

30 Sep 2025 04:22AM UTC coverage: 0.0% (-22.0%) from 21.956%
18118664137

Pull #7397

github

web-flow
Merge d1e60d9d5 into 55fd65795
Pull Request #7397: fix(jsonschema/jsonld): make `@id` and `@type` properties required only in the JSON-LD schema for output

0 of 17 new or added lines in 2 files covered. (0.0%)

12143 existing lines in 402 files now uncovered.

0 of 53916 relevant lines covered (0.0%)

0.0 hits per line

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

0.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';
×
35
    }
36

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

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

56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function configureDependencies(DependencyBuilder $dependencies): void
60
    {
UNCOV
61
    }
×
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'));
×
UNCOV
71
        $type = SupportedFilterTypes::tryFrom($typeArgument);
×
UNCOV
72
        if (null === $type) {
×
UNCOV
73
            throw new InvalidArgumentException(\sprintf('The type "%s" is not a valid filter type, valid options are: %s.', $typeArgument, self::getFilterTypesAsString()));
×
74
        }
75

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

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

UNCOV
88
        $generator->writeChanges();
×
89

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

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

UNCOV
100
        return implode(' or ', array_map('strtoupper', $validOptions));
×
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