Open Monograph Press  3.3.0
ClosureCacheAdapter.php
1 <?php
2 
3 namespace Guzzle\Cache;
4 
9 {
13  protected $callables;
14 
26  public function __construct(array $callables)
27  {
28  // Validate each key to ensure it exists and is callable
29  foreach (array('contains', 'delete', 'fetch', 'save') as $key) {
30  if (!array_key_exists($key, $callables) || !is_callable($callables[$key])) {
31  throw new \InvalidArgumentException("callables must contain a callable {$key} key");
32  }
33  }
34 
35  $this->callables = $callables;
36  }
37 
38  public function contains($id, array $options = null)
39  {
40  return call_user_func($this->callables['contains'], $id, $options);
41  }
42 
43  public function delete($id, array $options = null)
44  {
45  return call_user_func($this->callables['delete'], $id, $options);
46  }
47 
48  public function fetch($id, array $options = null)
49  {
50  return call_user_func($this->callables['fetch'], $id, $options);
51  }
52 
53  public function save($id, $data, $lifeTime = false, array $options = null)
54  {
55  return call_user_func($this->callables['save'], $id, $data, $lifeTime, $options);
56  }
57 }
Guzzle\Cache\CacheAdapterInterface
Definition: CacheAdapterInterface.php:12
Guzzle\Cache\ClosureCacheAdapter\save
save($id, $data, $lifeTime=false, array $options=null)
Definition: ClosureCacheAdapter.php:56
Guzzle\Cache\ClosureCacheAdapter\fetch
fetch($id, array $options=null)
Definition: ClosureCacheAdapter.php:51
Guzzle\Cache\ClosureCacheAdapter\__construct
__construct(array $callables)
Definition: ClosureCacheAdapter.php:29
Guzzle\Cache\ClosureCacheAdapter\$callables
$callables
Definition: ClosureCacheAdapter.php:16
Guzzle\Cache
Definition: AbstractCacheAdapter.php:3
Guzzle\Cache\ClosureCacheAdapter\contains
contains($id, array $options=null)
Definition: ClosureCacheAdapter.php:41
Guzzle\Cache\ClosureCacheAdapter
Definition: ClosureCacheAdapter.php:8