forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpyPaginator.php
More file actions
59 lines (49 loc) · 1.4 KB
/
Copy pathSpyPaginator.php
File metadata and controls
59 lines (49 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Tests\Fixtures\TestBundle\State;
use ApiPlatform\State\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* A paginator whose scalar metadata is canned but whose rows are never meant to be
* read: getIterator() and count() throw. A HEAD request must return without iterating,
* proving no row SELECT was issued.
*
* @implements PaginatorInterface<object>
* @implements \IteratorAggregate<object>
*/
final class SpyPaginator implements PaginatorInterface, \IteratorAggregate
{
public function getCurrentPage(): float
{
return 1.;
}
public function getItemsPerPage(): float
{
return 30.;
}
public function getLastPage(): float
{
return 1.;
}
public function getTotalItems(): float
{
return 42.;
}
public function count(): int
{
throw new HttpException(Response::HTTP_I_AM_A_TEAPOT, 'iterated on HEAD');
}
public function getIterator(): \Iterator
{
throw new HttpException(Response::HTTP_I_AM_A_TEAPOT, 'iterated on HEAD');
}
}