Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / annotated-command / src / Cache / CacheWrapper.php
1 <?php
2 namespace Consolidation\AnnotatedCommand\Cache;
3
4 /**
5  * Make a generic cache object conform to our expected interface.
6  */
7 class CacheWrapper implements SimpleCacheInterface
8 {
9     protected $dataStore;
10
11     public function __construct($dataStore)
12     {
13         $this->dataStore = $dataStore;
14     }
15
16     /**
17      * Test for an entry from the cache
18      * @param string $key
19      * @return boolean
20      */
21     public function has($key)
22     {
23         if (method_exists($this->dataStore, 'has')) {
24             return $this->dataStore->has($key);
25         }
26         $test = $this->dataStore->get($key);
27         return !empty($test);
28     }
29
30     /**
31      * Get an entry from the cache
32      * @param string $key
33      * @return array
34      */
35     public function get($key)
36     {
37         return (array) $this->dataStore->get($key);
38     }
39
40     /**
41      * Store an entry in the cache
42      * @param string $key
43      * @param array $data
44      */
45     public function set($key, $data)
46     {
47         $this->dataStore->set($key, $data);
48     }
49 }