setHits() public method

Set the hits property
public setHits ( integer $hits ) : self
$hits integer The amount of query hits
return self
Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getGroups(GroupQuery $query = null, GroupsModel $model)
 {
     if ($query === null) {
         $query = new GroupQuery();
     }
     $model->setHits(count($this->groups));
     $offset = ($query->page() - 1) * $query->limit();
     return array_slice($this->groups, $offset, $query->limit(), true);
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function getGroups(GroupQuery $query = null, GroupsModel $model)
 {
     if ($query === null) {
         $query = new GroupQuery();
     }
     $cursor = $this->getGroupsCollection()->find([], ['skip' => ($query->page() - 1) * $query->limit(), 'limit' => $query->limit()]);
     $groups = [];
     foreach ($cursor as $group) {
         $groups[$group['name']] = $group['resources']->getArrayCopy();
     }
     // Cache the retrieved groups
     $this->groups = array_merge($this->groups, $groups);
     // Update model with total hits
     $model->setHits($this->getGroupsCollection()->count());
     return $groups;
 }
Beispiel #3
0
 /**
  * @covers Imbo\Model\Groups::setHits
  * @covers Imbo\Model\Groups::getHits
  */
 public function testCanSetAndGetHits()
 {
     $this->assertNull($this->model->getHits());
     $this->assertSame($this->model, $this->model->setHits(10));
     $this->assertSame(10, $this->model->getHits());
 }