We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 9 | class Paginator |
||
| 10 | { |
||
| 11 | public const MODE_REGULAR = false; |
||
| 12 | public const MODE_PROMISE = true; |
||
| 13 | |||
| 14 | /** @var callable */ |
||
| 15 | private $fetcher; |
||
| 16 | |||
| 17 | /** @var bool */ |
||
| 18 | private $promise; |
||
| 19 | |||
| 20 | /** @var int */ |
||
| 21 | private $totalCount; |
||
| 22 | |||
| 23 | /** @var ConnectionBuilder */ |
||
| 24 | private $connectionBuilder; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param callable $fetcher |
||
| 28 | * @param bool $promise |
||
| 29 | */ |
||
| 30 | 14 | public function __construct(callable $fetcher, bool $promise = self::MODE_REGULAR, ConnectionBuilder $connectionBuilder = null) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param Argument $args |
||
| 39 | * @param int|callable $total |
||
| 40 | * @param array $callableArgs |
||
| 41 | * |
||
| 42 | * @return ConnectionInterface|object A connection or a promise |
||
| 43 | */ |
||
| 44 | 7 | public function backward($args, $total, array $callableArgs = []) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @param Argument $args |
||
| 64 | * |
||
| 65 | * @return ConnectionInterface|object A connection or a promise |
||
| 66 | */ |
||
| 67 | 7 | public function forward(Argument $args) |
|
| 91 | |||
| 92 | /** |
||
| 93 | * @param Argument $args |
||
| 94 | * @param int|callable $total |
||
| 95 | * @param array $callableArgs |
||
| 96 | * |
||
| 97 | * @return ConnectionInterface|object A connection or a promise |
||
| 98 | */ |
||
| 99 | 5 | public function auto(Argument $args, $total, array $callableArgs = []) |
|
| 121 | |||
| 122 | /** |
||
| 123 | * @param array|object $entities An array of entities to paginate or a promise |
||
| 124 | * @param callable $callback |
||
| 125 | * |
||
| 126 | * @return ConnectionInterface|object A connection or a promise |
||
| 127 | */ |
||
| 128 | 14 | private function handleEntities($entities, callable $callback) |
|
| 136 | |||
| 137 | /** |
||
| 138 | * @param Argument|array $args |
||
| 139 | * |
||
| 140 | * @return Argument |
||
| 141 | */ |
||
| 142 | 14 | private function protectArgs($args): Argument |
|
| 146 | |||
| 147 | /** |
||
| 148 | * @param int|callable $total |
||
| 149 | * @param array $callableArgs |
||
| 150 | * |
||
| 151 | * @return int|mixed |
||
| 152 | */ |
||
| 153 | 8 | private function computeTotalCount($total, array $callableArgs = []) |
|
| 163 | } |
||
| 164 |