예제 #1
0
 public function testCreate()
 {
     $pagination = new Pagination(10, 1, false);
     $pagination->setTotal(100);
     $this->assertSame(10, $pagination->getMaxResults());
     $this->assertSame(1, $pagination->getPage());
     $this->assertSame(100, $pagination->getTotal());
     $this->assertTrue($pagination->isTotalIncluded());
     $this->assertFalse($pagination->shouldIncludeTotal());
 }
예제 #2
0
 /**
  * @param Pagination|null $pagination
  * @return self
  */
 public function paginate(Pagination &$pagination = null)
 {
     if ($pagination === null) {
         return $this;
     }
     if ($pagination->shouldIncludeTotal()) {
         $paginator = new Paginator($this);
         $pagination->setTotal(count($paginator));
     }
     return $this->setFirstResult($pagination->getMaxResults() * ($pagination->getPage() - 1))->setMaxResults($pagination->getMaxResults());
 }