1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Collection; |
4: | |
5: | /** |
6: | * @api |
7: | * |
8: | * @template TKey of array-key |
9: | * @template TValue |
10: | */ |
11: | trait ArrayableCollectionTrait |
12: | { |
13: | /** @use HasItems<TKey,TValue> */ |
14: | use HasItems; |
15: | |
16: | /** |
17: | * @inheritDoc |
18: | */ |
19: | public function toArray(bool $preserveKeys = true): array |
20: | { |
21: | return $preserveKeys |
22: | ? $this->Items |
23: | : array_values($this->Items); |
24: | } |
25: | } |
26: |