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

api-platform / core / 21006071786

14 Jan 2026 06:53PM UTC coverage: 21.366% (-7.7%) from 29.097%
21006071786

Pull #7675

github

web-flow
Merge 5c98a7330 into 73402fc61
Pull Request #7675: feat(doctrine): Add caseInsensitive option to PartialSearchFilter

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

15054 existing lines in 491 files now uncovered.

12306 of 57596 relevant lines covered (21.37%)

49.15 hits per line

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

95.0
/src/Hydra/State/Util/PaginationHelperTrait.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\Hydra\State\Util;
15

16
use ApiPlatform\Hydra\PartialCollectionView;
17
use ApiPlatform\Metadata\UrlGeneratorInterface;
18
use ApiPlatform\Metadata\Util\IriHelper;
19
use ApiPlatform\State\Pagination\PaginatorInterface;
20
use ApiPlatform\State\Pagination\PartialPaginatorInterface;
21

22
trait PaginationHelperTrait
23
{
24
    private function getPaginationIri(array $parsed, ?float $currentPage, ?float $lastPage, ?float $itemsPerPage, ?float $pageTotalItems, ?int $urlGenerationStrategy, string $pageParameterName): array
25
    {
UNCOV
26
        $first = $last = $previous = $next = null;
129✔
27

UNCOV
28
        if (null !== $lastPage) {
129✔
UNCOV
29
            $first = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $pageParameterName, 1., $urlGenerationStrategy);
128✔
UNCOV
30
            $last = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $pageParameterName, $lastPage, $urlGenerationStrategy);
128✔
31
        }
32

UNCOV
33
        if (1. !== $currentPage) {
129✔
UNCOV
34
            $previous = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $pageParameterName, $currentPage - 1., $urlGenerationStrategy);
12✔
35
        }
36

UNCOV
37
        if ((null !== $lastPage && $currentPage < $lastPage) || (null === $lastPage && $pageTotalItems >= $itemsPerPage)) {
129✔
UNCOV
38
            $next = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $pageParameterName, $currentPage + 1., $urlGenerationStrategy);
127✔
39
        }
40

UNCOV
41
        return [
129✔
UNCOV
42
            'first' => $first,
129✔
UNCOV
43
            'last' => $last,
129✔
UNCOV
44
            'previous' => $previous,
129✔
UNCOV
45
            'next' => $next,
129✔
UNCOV
46
        ];
129✔
47
    }
48

49
    private function getPartialCollectionView(mixed $object, string $requestUri, string $pageParameterName, string $enabledParameterName, ?int $urlGenerationStrategy = UrlGeneratorInterface::ABS_PATH): PartialCollectionView
50
    {
UNCOV
51
        $currentPage = $lastPage = $itemsPerPage = $pageTotalItems = null;
221✔
UNCOV
52
        $paginated = false;
221✔
UNCOV
53
        if ($object instanceof PartialPaginatorInterface) {
221✔
UNCOV
54
            $paginated = true;
220✔
UNCOV
55
            if ($object instanceof PaginatorInterface) {
220✔
UNCOV
56
                $paginated = 1. !== $lastPage = $object->getLastPage();
219✔
57
            } else {
58
                $itemsPerPage = $object->getItemsPerPage();
1✔
59
                $pageTotalItems = (float) \count($object);
1✔
60
            }
UNCOV
61
            $currentPage = $object->getCurrentPage();
220✔
62
        }
63

UNCOV
64
        $parsed = IriHelper::parseIri($requestUri, $pageParameterName);
221✔
UNCOV
65
        $appliedFilters = $parsed['parameters'];
221✔
UNCOV
66
        unset($appliedFilters[$enabledParameterName]);
221✔
67

UNCOV
68
        $id = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $pageParameterName, $paginated ? $currentPage : null, $urlGenerationStrategy);
221✔
69

UNCOV
70
        if (!$paginated && $appliedFilters) {
221✔
UNCOV
71
            return new PartialCollectionView($id);
96✔
72
        }
73

UNCOV
74
        ['first' => $first, 'last' => $last, 'previous' => $previous, 'next' => $next] = $this->getPaginationIri($parsed, $currentPage, $lastPage, $itemsPerPage, $pageTotalItems, $urlGenerationStrategy, $pageParameterName);
129✔
75

UNCOV
76
        if (!$paginated) {
129✔
UNCOV
77
            $first = null;
×
UNCOV
78
            $last = null;
×
79
        }
80

UNCOV
81
        return new PartialCollectionView(
129✔
UNCOV
82
            $id,
129✔
UNCOV
83
            $first,
129✔
UNCOV
84
            $last,
129✔
UNCOV
85
            $previous,
129✔
UNCOV
86
            $next
129✔
UNCOV
87
        );
129✔
88
    }
89
}
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