1: <?php declare(strict_types=1);
2:
3: namespace Salient\Curler\Pager;
4:
5: use Salient\Utility\Arr;
6: use Closure;
7:
8: /**
9: * @api
10: */
11: trait HasEntitySelector
12: {
13: /** @var Closure(mixed): list<mixed> */
14: private Closure $EntitySelector;
15:
16: /**
17: * @param (Closure(mixed): list<mixed>)|array-key|null $entitySelector
18: */
19: private function applyEntitySelector($entitySelector): void
20: {
21: $this->EntitySelector = $entitySelector instanceof Closure
22: ? $entitySelector
23: : ($entitySelector === null
24: ? fn($data) => Arr::wrapList($data)
25: : fn($data) => Arr::wrapList(Arr::get($data, (string) $entitySelector)));
26: }
27: }
28: