- $count = count( $rows );
- if ( !$count ) {
- return [ [], null ]; // nothing to do
- } elseif ( $count < $limit ) {
- return [ $rows, $rows[$count - 1]->$column ]; // no more rows left
+
+ // Nothing to do
+ if ( !$rows ) {
+ return [ [], null ];
+ }
+
+ $lastValue = end( $rows )->$column;
+ if ( count( $rows ) < $limit ) {
+ return [ $rows, $lastValue ];