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

api-platform / core / 7927935469

16 Feb 2024 08:27AM UTC coverage: 63.835% (-0.02%) from 63.85%
7927935469

push

github

web-flow
fix(hydra): remove dependency from ApiPlatform/Api dependency (#6154)

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

31 existing lines in 14 files now uncovered.

17042 of 26697 relevant lines covered (63.83%)

31.23 hits per line

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

0.0
/src/Api/FilterLocatorTrait.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\Api;
15

16
use ApiPlatform\Exception\InvalidArgumentException;
17
use ApiPlatform\Metadata\FilterInterface as MetadataFilterInterface;
18
use Psr\Container\ContainerInterface;
19

20
/**
21
 * Manipulates filters with a backward compatibility between the new filter locator and the deprecated filter collection.
22
 *
23
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
24
 *
25
 * @deprecated
26
 *
27
 * @internal
28
 */
29
trait FilterLocatorTrait
30
{
31
    private ?ContainerInterface $filterLocator = null;
32

33
    /**
34
     * Sets a filter locator with a backward compatibility.
35
     */
36
    private function setFilterLocator(?ContainerInterface $filterLocator, bool $allowNull = false): void
37
    {
UNCOV
38
        if ($filterLocator instanceof ContainerInterface || (null === $filterLocator && $allowNull)) {
×
UNCOV
39
            $this->filterLocator = $filterLocator;
×
40
        } else {
41
            throw new InvalidArgumentException(sprintf('The "$filterLocator" argument is expected to be an implementation of the "%s" interface%s.', ContainerInterface::class, $allowNull ? ' or null' : ''));
×
42
        }
43
    }
44

45
    /**
46
     * Gets a filter with a backward compatibility.
47
     */
48
    private function getFilter(string $filterId): FilterInterface|MetadataFilterInterface|null
49
    {
UNCOV
50
        if ($this->filterLocator && $this->filterLocator->has($filterId)) {
×
UNCOV
51
            return $this->filterLocator->get($filterId);
×
52
        }
53

UNCOV
54
        return null;
×
55
    }
56
}
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