Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractCacheAdapter
  • CacheAdapterFactory
  • ClosureCacheAdapter
  • DoctrineCacheAdapter
  • NullCacheAdapter
  • Zf1CacheAdapter
  • Zf2CacheAdapter

Interfaces

  • CacheAdapterInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Cache;
 4: 
 5: /**
 6:  * Cache adapter that defers to closures for implementation
 7:  */
 8: class ClosureCacheAdapter implements CacheAdapterInterface
 9: {
10:     /**
11:      * @var array Mapping of method names to callables
12:      */
13:     protected $callables;
14: 
15:     /**
16:      * The callables array is an array mapping the actions of the cache adapter to callables.
17:      * - contains: Callable that accepts an $id and $options argument
18:      * - delete:   Callable that accepts an $id and $options argument
19:      * - fetch:    Callable that accepts an $id and $options argument
20:      * - save:     Callable that accepts an $id, $data, $lifeTime, and $options argument
21:      *
22:      * @param array $callables array of action names to callable
23:      *
24:      * @throws \InvalidArgumentException if the callable is not callable
25:      */
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:     /**
39:      * {@inheritdoc}
40:      */
41:     public function contains($id, array $options = null)
42:     {
43:         return call_user_func($this->callables['contains'], $id, $options);
44:     }
45: 
46:     /**
47:      * {@inheritdoc}
48:      */
49:     public function delete($id, array $options = null)
50:     {
51:         return call_user_func($this->callables['delete'], $id, $options);
52:     }
53: 
54:     /**
55:      * {@inheritdoc}
56:      */
57:     public function fetch($id, array $options = null)
58:     {
59:         return call_user_func($this->callables['fetch'], $id, $options);
60:     }
61: 
62:     /**
63:      * {@inheritdoc}
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: 
php-coveralls API documentation generated by ApiGen 2.8.0