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

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

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

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 hits per line

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

75.0
/src/Doctrine/Orm/AbstractPaginator.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\Doctrine\Orm;
15

16
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
17
use ApiPlatform\State\Pagination\PartialPaginatorInterface;
18
use Doctrine\ORM\Query;
19
use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator;
20

21
abstract class AbstractPaginator implements \IteratorAggregate, PartialPaginatorInterface
22
{
23
    protected DoctrinePaginator $paginator;
24
    protected array|\Traversable $iterator;
25
    protected ?int $firstResult;
26
    protected ?int $maxResults;
27

28
    /**
29
     * @throws InvalidArgumentException
30
     */
31
    public function __construct(DoctrinePaginator $paginator)
32
    {
UNCOV
33
        $query = $paginator->getQuery();
104✔
34

UNCOV
35
        if (null === ($firstResult = $query->getFirstResult()) || $firstResult < 0 || null === $maxResults = $query->getMaxResults()) { // @phpstan-ignore-line
104✔
36
            throw new InvalidArgumentException(\sprintf('"%1$s::setFirstResult()" or/and "%1$s::setMaxResults()" was/were not applied to the query.', Query::class));
×
37
        }
38

UNCOV
39
        $this->paginator = $paginator;
104✔
UNCOV
40
        $this->firstResult = $firstResult;
104✔
UNCOV
41
        $this->maxResults = $maxResults;
104✔
42
    }
43

44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getCurrentPage(): float
48
    {
UNCOV
49
        if (0 >= $this->maxResults) {
102✔
50
            return 1.;
×
51
        }
52

UNCOV
53
        return floor($this->firstResult / $this->maxResults) + 1.;
102✔
54
    }
55

56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function getItemsPerPage(): float
60
    {
UNCOV
61
        return (float) $this->maxResults;
4✔
62
    }
63

64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getIterator(): \Traversable
68
    {
UNCOV
69
        return $this->iterator ?? $this->iterator = $this->paginator->getIterator();
104✔
70
    }
71

72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function count(): int
76
    {
77
        return iterator_count($this->getIterator());
×
78
    }
79
}
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