Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Remove usage of Timber\PostCollection in Repository
Browse files Browse the repository at this point in the history
- See gihub issues #53 & #54
  • Loading branch information
perruche committed Jun 28, 2021
1 parent 794f861 commit 6eea3b7
Showing 1 changed file with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

namespace Studiometa\Repositories;

use Timber\PostCollection;

/** Class */
abstract class Repository {
/**
Expand Down Expand Up @@ -39,32 +37,10 @@ public function first() {
return isset( $local_array[0] ) ? $local_array[0] : null;
}

/**
* Returns a slice of the collection starting at the given index.
* Similar to Laravel's slice().
*
* @param int $start Start index.
*
* @return array
*/
public function slice( $start ) {
$local_array = $this->get();

if ( count( $local_array ) < 1 ) {
return array();
}

if ( is_object( $local_array ) && $local_array instanceof PostCollection ) {
$local_array = $local_array->getArrayCopy();
}

return array_slice( $local_array, (int) $start );
}

/**
* Runs a query.
*
* @param array $params Query params.
* @param array $params Query params.
*
* @return Repository
*/
Expand Down Expand Up @@ -95,7 +71,7 @@ protected function query( array $params ) {
*
* Define the query the Repository will run.
*
* @param array $params Query params.
* @param array $params Query params.
* @return mixed
*/
abstract protected function do_query( $params );
Expand Down

0 comments on commit 6eea3b7

Please sign in to comment.