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

api-platform / core / 3712739783

pending completion
3712739783

Pull #5254

github

GitHub
Merge 9dfa88fa6 into ac711530f
Pull Request #5254: [OpenApi] Add ApiResource::openapi and deprecate openapiContext

199 of 199 new or added lines in 6 files covered. (100.0%)

7494 of 12363 relevant lines covered (60.62%)

67.55 hits per line

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

77.78
/src/State/CallableProcessor.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\State;
15

16
use ApiPlatform\Exception\RuntimeException;
17
use ApiPlatform\Metadata\Operation;
18
use Psr\Container\ContainerInterface;
19

20
final class CallableProcessor implements ProcessorInterface
21
{
22
    public function __construct(private readonly ContainerInterface $locator)
23
    {
24
    }
586✔
25

26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
30
    {
31
        if (!($processor = $operation->getProcessor())) {
170✔
32
            return null;
2✔
33
        }
34

35
        if (\is_callable($processor)) {
168✔
36
            return $processor($data, $operation, $uriVariables, $context);
×
37
        }
38

39
        if (!$this->locator->has($processor)) {
168✔
40
            throw new RuntimeException(sprintf('Processor "%s" not found on operation "%s"', $processor, $operation->getName()));
×
41
        }
42

43
        /** @var ProcessorInterface $processorInstance */
44
        $processorInstance = $this->locator->get($processor);
168✔
45

46
        return $processorInstance->process($data, $operation, $uriVariables, $context);
168✔
47
    }
48
}
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

© 2025 Coveralls, Inc