Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
|
|
3 |
namespace Nuwave\Lighthouse\Pagination; |
|
4 |
|
|
5 |
use Nuwave\Lighthouse\Exceptions\DefinitionException; |
|
6 |
|
|
7 |
/**
|
|
8 |
* An enum-like class that contains the supported types of pagination.
|
|
9 |
*/
|
|
10 |
class PaginationType |
|
11 |
{
|
|
12 |
public const PAGINATOR = 'PAGINATOR'; |
|
13 |
public const CONNECTION = 'CONNECTION'; |
|
14 |
|
|
15 |
/**
|
|
16 |
* @var string One of the constant values in this class
|
|
17 |
*/
|
|
18 |
protected $type; |
|
19 |
|
|
20 |
/**
|
|
21 |
* @throws \Nuwave\Lighthouse\Exceptions\DefinitionException
|
|
22 |
*/
|
|
23 | 1 |
public function __construct(string $paginationType) |
24 |
{
|
|
25 |
// TODO remove lowercase and alternate options in v6
|
|
26 | 1 |
switch (strtolower($paginationType)) { |
27 | 1 |
case 'default': |
28 | 1 |
case 'paginator': |
29 | 1 |
$this->type = self::PAGINATOR; |
30 | 1 |
break; |
31 | 1 |
case 'connection': |
32 | 1 |
case 'relay': |
33 | 1 |
$this->type = self::CONNECTION; |
34 | 1 |
break; |
35 |
default: |
|
36 | 1 |
throw new DefinitionException( |
37 | 1 |
"Found invalid pagination type: {$paginationType}" |
38 |
);
|
|
39 |
}
|
|
40 |
}
|
|
41 |
|
|
42 |
public function isPaginator(): bool |
|
43 |
{
|
|
44 |
return $this->type === self::PAGINATOR; |
|
45 |
}
|
|
46 |
|
|
47 | 1 |
public function isConnection(): bool |
48 |
{
|
|
49 | 1 |
return $this->type === self::CONNECTION; |
50 |
}
|
|
51 |
}
|
Read our documentation on viewing source code .