Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added PeepService

- Returns paginators for the fetch(User)?Timeline() methods, otherwise delegates
  to the composed PeepTable object
  • Loading branch information...
commit 5c712ee90d4739db4d693c0b12367a8920bdc0ee 1 parent b5b821e
@weierophinney authored
Showing with 72 additions and 0 deletions.
  1. +72 −0 src/PhlyPeep/Model/PeepService.php
View
72 src/PhlyPeep/Model/PeepService.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace PhlyPeep\Model;
+
+class PeepService
+{
+ protected $pageSize = 20;
+ protected $table;
+
+ public function __construct(PeepTable $table)
+ {
+ $this->table = $table;
+ }
+
+ /**
+ * Set value for page size
+ *
+ * @param int $pageSize
+ * @return PeepService
+ */
+ public function setPageSize($pageSize)
+ {
+ $this->pageSize = (int) $pageSize;
+ return $this;
+ }
+
+ /**
+ * Get value for page size
+ *
+ * @return int
+ */
+ public function getPageSize()
+ {
+ return $this->pageSize;
+ }
+
+ public function fetchTimeline($page = 1)
+ {
+ $paginator = $this->getTimelinePaginator($page);
+ return $paginator;
+ }
+
+ public function fetchUserTimeline($user, $page = 1)
+ {
+ $paginator = $this->getUserTimelinePaginator($user, $page);
+ return $paginator;
+ }
+
+ public function fetchPeep($identifier)
+ {
+ return $this->table->fetchPeep($identifier);
+ }
+
+ public function insertPeep(PeepEntity $peep)
+ {
+ $this->table->insertPeep($peep);
+ }
+
+ protected function getTimelinePaginator($page)
+ {
+ $paginator = new Paginator(new PeepPaginator($this->table, PeepPaginator::TYPE_ALL));
+ $paginator->setCurrentPageNumber($page);
+ return $paginator;
+ }
+
+ protected function getUserTimelinePaginator($user, $page)
+ {
+ $paginator = new Paginator(new PeepPaginator($this->table, PeepPaginator::TYPE_USER, $user));
+ $paginator->setCurrentPageNumber($page);
+ return $paginator;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.