1: <?php
2:
3: namespace Guzzle\Cache;
4:
5: 6: 7:
8: class ClosureCacheAdapter implements CacheAdapterInterface
9: {
10: 11: 12:
13: protected $callables;
14:
15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: public function __construct(array $callables)
27: {
28:
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: 39: 40:
41: public function contains($id, array $options = null)
42: {
43: return call_user_func($this->callables['contains'], $id, $options);
44: }
45:
46: 47: 48:
49: public function delete($id, array $options = null)
50: {
51: return call_user_func($this->callables['delete'], $id, $options);
52: }
53:
54: 55: 56:
57: public function fetch($id, array $options = null)
58: {
59: return call_user_func($this->callables['fetch'], $id, $options);
60: }
61:
62: 63: 64:
65: public function save($id, $data, $lifeTime = false, array $options = null)
66: {
67: return call_user_func($this->callables['save'], $id, $data, $lifeTime, $options);
68: }
69: }
70: