상속: extends Psr\Cache\CacheItemInterface
예제 #1
0
 function it_expands_a_url(Provider $provider, PoolInterface $pool, ItemInterface $item)
 {
     $item->isMiss()->willReturn(true);
     $item->set('http://any.url')->shouldBeCalled();
     $pool->getItem(md5('http://short.ly/1234'))->willReturn($item);
     $provider->expand('http://short.ly/1234')->willReturn('http://any.url');
     $this->expand('http://short.ly/1234')->shouldReturn('http://any.url');
 }
예제 #2
0
파일: User.php 프로젝트: lullabot/mpx-php
 /**
  * {@inheritdoc}
  */
 public function signOut()
 {
     $token = $this->tokenCache->get();
     if ($token && !$this->tokenCache->isMiss()) {
         $this->getClient()->get('https://identity.auth.theplatform.com/idm/web/Authentication/signOut', array('query' => array('schema' => '1.0', 'form' => 'json', '_token' => $token)));
         $this->getLogger()->info('Expired mpx authentication token {token} for {username}.', array('token' => $token, 'username' => $this->getUsername()));
     }
     $this->tokenCache->clear();
 }
예제 #3
0
 private function assertDisabledStash(\Stash\Interfaces\ItemInterface $item)
 {
     $this->assertFalse($item->set('true'), 'storeData returns false for disabled cache');
     $this->assertNull($item->get(), 'getData returns null for disabled cache');
     $this->assertFalse($item->clear(), 'clear returns false for disabled cache');
     $this->assertTrue($item->isMiss(), 'isMiss returns true for disabled cache');
     $this->assertFalse($item->extend(), 'extend returns false for disabled cache');
     $this->assertTrue($item->lock(100), 'lock returns true for disabled cache');
 }
예제 #4
0
 /**
  * @param ResponseInterface $response
  * @param ItemInterface     $item
  * @param array|null        $data
  *
  * @throws \RuntimeException
  *
  * @return array
  */
 protected function handleSuccessfulResponse(ResponseInterface $response, ItemInterface $item, $data)
 {
     switch ((int) $response->getStatusCode()) {
         case 200:
             $data = json_decode($response->getBody(), true);
             if ($response->hasHeader('Last-Modified') === true) {
                 $item->set(['modified' => $response->getHeader('Last-Modified'), 'json' => $data]);
             }
             return $data;
         case 304:
             return $data['json'];
         default:
             throw new \RuntimeException('No support added for HTTP Status Code ' . $response->getStatusCode());
     }
 }