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

api-platform / core / 18060089452

27 Sep 2025 12:57PM UTC coverage: 0.0% (-21.8%) from 21.793%
18060089452

Pull #7397

github

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

0 of 15 new or added lines in 1 file covered. (0.0%)

11967 existing lines in 393 files now uncovered.

0 of 53914 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/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;
×
27

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

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

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

UNCOV
41
        return [
×
UNCOV
42
            'first' => $first,
×
UNCOV
43
            'last' => $last,
×
UNCOV
44
            'previous' => $previous,
×
UNCOV
45
            'next' => $next,
×
UNCOV
46
        ];
×
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;
×
UNCOV
52
        $paginated = false;
×
UNCOV
53
        if ($object instanceof PartialPaginatorInterface) {
×
UNCOV
54
            $paginated = true;
×
UNCOV
55
            if ($object instanceof PaginatorInterface) {
×
UNCOV
56
                $paginated = 1. !== $lastPage = $object->getLastPage();
×
57
            } else {
58
                $itemsPerPage = $object->getItemsPerPage();
×
59
                $pageTotalItems = (float) \count($object);
×
60
            }
UNCOV
61
            $currentPage = $object->getCurrentPage();
×
62
        }
63

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

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

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

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

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

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