RecordCollection
A lazy, immutable list of records.
Paths hydrate into objects as you iterate.
Properties (1)
| $recordCollection->app | App | readonly |
- accepts Whether $item is an instance this collection is meant to hold.
- all Returns true if all items pass $fn (respects limit/offset).
- any Returns true if any item passes $fn (respects limit/offset).
- append Adds a record to the end; null is ignored.
- appendPath Append a page URI string for lazy loading on iteration.
- contains True if $item's type matches this collection and an item with the same uuid is already present.
- count Total number of items held, ignoring limit/offset.
- each Calls $fn for each item (respecting limit/offset) and returns self.
- filter Returns a new collection of items where the callback returns true.
- first The first record, or null when empty.
- getIterator Yields items respecting limit/offset, hydrating lazy paths in place.
- import Appends each record in $items.
- isEmpty Whether the collection holds no records.
- last The last record, or null when empty.
- limit Returns a new collection capped to $limit items on iteration.
- nth Returns the item at a 0-based index, or null if out of bounds.
- offset Returns a new collection that skips the first $offset items on iteration.
- paths The registry path of every item, ignoring limit/offset and hydrating nothing.
- pluck Returns an array of $field values from each item (respects limit/offset).
- reverse Returns a new collection with the items in reverse order.
- toArray Returns all items as a plain array, respecting limit/offset, hydrating any lazy paths.
- total How many records the whole query matches, ignoring limit/offset - what the builder supplied, else the items held.
Methods
$recordCollection->all(callable $fn): bool
Returns true if all items pass $fn (respects limit/offset).
True for empty collections.
Parameters (1)
| $fn | callable |
Returns bool
phlat/src/Collections/RecordCollection.php:186
$recordCollection->any(callable $fn): bool
Returns true if any item passes $fn (respects limit/offset).
Parameters (1)
| $fn | callable |
Returns bool
phlat/src/Collections/RecordCollection.php:176
$recordCollection->appendPath(string $path): self
Append a page URI string for lazy loading on iteration.
Parameters (1)
| $path | string |
Returns self
phlat/src/Collections/RecordCollection.php:41
$recordCollection->count(): int
Total number of items held, ignoring limit/offset.
Returns int
phlat/src/Collections/RecordCollection.php:81
$recordCollection->each(callable $fn): self
Calls $fn for each item (respecting limit/offset) and returns self.
Parameters (1)
| $fn | callable |
Returns self
phlat/src/Collections/RecordCollection.php:167
$recordCollection->filter(callable $fn): static
Returns a new collection of items where the callback returns true.
Ignores limit/offset.
Parameters (1)
| $fn | callable |
Returns static
phlat/src/Collections/RecordCollection.php:206
$recordCollection->getIterator(): Generator
Yields items respecting limit/offset, hydrating lazy paths in place.
Safe to nest - each loop gets its own generator.
Returns Generator
phlat/src/Collections/RecordCollection.php:222
$recordCollection->import(array $items): self
Appends each record in $items.
Parameters (1)
| $items | array |
Returns self
phlat/src/Collections/RecordCollection.php:48
$recordCollection->isEmpty(): bool
Whether the collection holds no records.
Returns bool
phlat/src/Collections/RecordCollection.php:130
$recordCollection->limit(int $limit): static
Returns a new collection capped to $limit items on iteration.
Parameters (1)
| $limit | int |
Returns static
phlat/src/Collections/RecordCollection.php:65
$recordCollection->offset(int $offset): static
Returns a new collection that skips the first $offset items on iteration.
Parameters (1)
| $offset | int |
Returns static
phlat/src/Collections/RecordCollection.php:73
$recordCollection->paths(): array
The registry path of every item, ignoring limit/offset and hydrating nothing.
Returns array
phlat/src/Collections/RecordCollection.php:151
$recordCollection->pluck(string $field): array
Returns an array of $field values from each item (respects limit/offset).
Parameters (1)
| $field | string |
Returns array
phlat/src/Collections/RecordCollection.php:196
$recordCollection->reverse(): static
Returns a new collection with the items in reverse order.
Returns static
phlat/src/Collections/RecordCollection.php:57
$recordCollection->toArray(): array
Returns all items as a plain array, respecting limit/offset, hydrating any lazy paths.
Returns array
phlat/src/Collections/RecordCollection.php:157
$recordCollection->total(): int
How many records the whole query matches, ignoring limit/offset - what the builder supplied, else the items held.
Pagination reads this.
Returns int
phlat/src/Collections/RecordCollection.php:87