예제 #1
0
 private function getExistingAdapterMock()
 {
     $existingAdapterMock = $this->prophesize(AdapterInterface::class);
     $existingAdapterMock->exists(Argument::type(IdentifierInterface::class))->willReturn(true);
     $existingAdapterMock->get(Argument::type(IdentifierInterface::class))->willReturn($this->blockMock->reveal());
     return $existingAdapterMock;
 }
예제 #2
0
 /**
  * @inheritDoc
  */
 public function validate(BlockInterface $block)
 {
     $now = new \DateTime();
     $updatedAt = $block->getUpdatedAt();
     $interval = $updatedAt->diff($now);
     $diffInSeconds = $this->intervalToSeconds($interval);
     return $this->expire > $diffInSeconds;
 }
예제 #3
0
 /**
  * @inheritDoc
  */
 public function remove(BlockInterface $block)
 {
     if (!$this->exists($block->getIdentifier())) {
         return false;
     }
     $filename = $this->getFilename($block->getIdentifier());
     if (false === unlink($filename)) {
         throw new \Exception('Unlink failed');
     }
     return true;
 }