We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
17 | class ConnectionBuilder |
||
18 | { |
||
19 | public const PREFIX = 'arrayconnection:'; |
||
20 | |||
21 | /** |
||
22 | * If set, used to generate the connection object. |
||
23 | * |
||
24 | * @var callable |
||
25 | */ |
||
26 | protected $connectionCallback; |
||
27 | |||
28 | /** |
||
29 | * If set, used to generate the edge object. |
||
30 | * |
||
31 | * @var callable |
||
32 | */ |
||
33 | protected $edgeCallback; |
||
34 | |||
35 | public function __construct(callable $connectionCallback = null, callable $edgeCallback = null) |
||
40 | |||
41 | /** |
||
42 | * A simple function that accepts an array and connection arguments, and returns |
||
43 | * a connection object for use in GraphQL. It uses array offsets as pagination, |
||
44 | * so pagination will only work if the array is static. |
||
45 | * |
||
46 | * @param array $data |
||
47 | * @param array|Argument $args |
||
48 | * |
||
49 | * @return Connection |
||
50 | */ |
||
51 | public function connectionFromArray(array $data, $args = []): Connection |
||
62 | |||
63 | /** |
||
64 | * A version of `connectionFromArray` that takes a promised array, and returns a |
||
65 | * promised connection. |
||
66 | * |
||
67 | * @param mixed $dataPromise a promise |
||
68 | * @param array|Argument $args |
||
69 | * |
||
70 | * @return mixed a promise |
||
71 | */ |
||
72 | public function connectionFromPromisedArray($dataPromise, $args = []) |
||
80 | |||
81 | /** |
||
82 | * Given a slice (subset) of an array, returns a connection object for use in |
||
83 | * GraphQL. |
||
84 | * |
||
85 | * This function is similar to `connectionFromArray`, but is intended for use |
||
86 | * cases where you know the cardinality of the connection, consider it too large |
||
87 | * to materialize the entire array, and instead wish pass in a slice of the |
||
88 | * total result large enough to cover the range specified in `args`. |
||
89 | * |
||
90 | * @param array $arraySlice |
||
91 | * @param array|Argument $args |
||
92 | * @param array $meta |
||
93 | * |
||
94 | * @return Connection |
||
95 | */ |
||
96 | public function connectionFromArraySlice(array $arraySlice, $args, array $meta): Connection |
||
192 | |||
193 | /** |
||
194 | * A version of `connectionFromArraySlice` that takes a promised array slice, |
||
195 | * and returns a promised connection. |
||
196 | * |
||
197 | * @param mixed $dataPromise a promise |
||
198 | * @param array|Argument $args |
||
199 | * @param array $meta |
||
200 | * |
||
201 | * @return mixed a promise |
||
202 | */ |
||
203 | public function connectionFromPromisedArraySlice($dataPromise, $args, array $meta) |
||
211 | |||
212 | /** |
||
213 | * Return the cursor associated with an object in an array. |
||
214 | * |
||
215 | * @param array $data |
||
216 | * @param mixed $object |
||
217 | * |
||
218 | * @return null|string |
||
219 | */ |
||
220 | public function cursorForObjectInConnection(array $data, $object): ? string |
||
240 | |||
241 | /** |
||
242 | * Given an optional cursor and a default offset, returns the offset |
||
243 | * to use; if the cursor contains a valid offset, that will be used, |
||
244 | * otherwise it will be the default. |
||
245 | * |
||
246 | * @param string|null $cursor |
||
247 | * @param int $defaultOffset |
||
248 | * |
||
249 | * @return int |
||
250 | */ |
||
251 | public function getOffsetWithDefault(? string $cursor, int $defaultOffset): int |
||
260 | |||
261 | /** |
||
262 | * Creates the cursor string from an offset. |
||
263 | * |
||
264 | * @param $offset |
||
265 | * |
||
266 | * @return string |
||
267 | */ |
||
268 | public function offsetToCursor($offset): string |
||
272 | |||
273 | /** |
||
274 | * Redefines the offset from the cursor string. |
||
275 | * |
||
276 | * @param $cursor |
||
277 | * |
||
278 | * @return string |
||
279 | */ |
||
280 | public function cursorToOffset($cursor): string |
||
288 | |||
289 | private function getOptionsWithDefaults(array $options, array $defaults) |
||
293 | |||
294 | private function checkPromise($value): void |
||
300 | } |
||
301 |