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

api-platform / core / 7196499749

13 Dec 2023 02:17PM UTC coverage: 37.359% (+1.4%) from 36.003%
7196499749

push

github

web-flow
ci: conflict sebastian/comparator (#6032)

* ci: conflict sebastian/comparator

* for lowest

10295 of 27557 relevant lines covered (37.36%)

28.14 hits per line

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

66.67
/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\Metadata\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 = null)
23
    {
24
    }
99✔
25

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

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

39
        if (!$this->locator->has($processor)) {
20✔
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);
20✔
45

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

© 2026 Coveralls, Inc