Ejemplo n.º 1
0
 function it_current()
 {
     $this->get()->shouldHaveType(AccessEntity::getClass());
 }
Ejemplo n.º 2
0
 /**
  * Clear olds token
  *
  * @param integer $day
  * @return true
  * @throws \RuntimeException
  */
 public function clearOld($day)
 {
     $time = $this->date()->convertTimeStamp(time() - $day * 3600 * 24);
     $filter = ['<' . AccessEntity::C_TIMESTAMP_X => $time];
     $repo = new Repository($this->repository_name);
     $entities = self::finder(AccessEntity::getClass())->filter($filter)->all();
     foreach ($entities as $entity) {
         $repo->delete($this, $entity);
     }
     if (!$repo->commit()) {
         $mess = print_r($repo->getErrorEntity()->getErrors()->all(), 1);
         throw new \RuntimeException("Error delete old access token. Error: {$mess}.");
     }
     return true;
 }