1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 08:04:05 +02:00

feat(element-queries): update slice() method #436

This commit is contained in:
Awilum
2020-07-15 21:53:43 +03:00
parent 0770e12986
commit 22a7867b9a

View File

@@ -375,13 +375,19 @@ class Collection
*
* @access public
*/
public function slice(int $offset = 0, ?int $limit = null) : array
public function slice(int $offset = 0, ?int $length = null) : array
{
$results = $this->matchCollection()->slice($offset, $limit);
// Match collection
$collection = $this->collection->matching($this->criteria);
return Arr::isAssoc($results) ?
array_undot(array_dot($results)) :
$results;
// Restore error_reporting
error_reporting($this->oldErrorReporting);
// Gets a native PHP array representation of the collection.
$results = $collection->slice($offset, $length);
// Return results
return $this->isAssocArray($results) ? array_undot(array_dot($results)) : $results;
}
/**