| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types = 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | namespace BrowscapPHP\Cache; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Psr\Log\LoggerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Psr\SimpleCache\CacheInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Psr\SimpleCache\InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * A cache proxy to be able to use the cache adapters provided by the WurflCache package | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | final class BrowscapCache implements BrowscapCacheInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * Path to the cache directory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @var \Psr\SimpleCache\CacheInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $cache = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @var \Psr\Log\LoggerInterface|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * Detected browscap version (read from INI file) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     private $version = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * Release date of the Browscap data (read from INI file) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     private $releaseDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * Type of the Browscap data (read from INI file) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     private $type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 5 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 5 |  |      * Constructor class, checks for the existence of (and loads) the cache and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 5 |  |      * if needed updated the definitions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @param \Psr\SimpleCache\CacheInterface $adapter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @param LoggerInterface $logger | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     public function __construct(CacheInterface $adapter, LoggerInterface $logger) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 2 |  |         $this->cache = $adapter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->logger = $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 2 |  |      * Gets the version of the Browscap data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 2 |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function getVersion() : ?int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         if ($this->version === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 2 |  |             $success = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 $version = $this->getItem('browscap.version', false, $success); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 $this->logger->error(new \InvalidArgumentException('an error occured while reading the data version from the cache', 0, $e)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 $version = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             if ($version !== null && $success) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 1 |  |                 $this->version = (int) $version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         return $this->version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * Gets the release date of the Browscap data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public function getReleaseDate() : ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         if ($this->releaseDate === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             $success = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 1 |  |                 $releaseDate = $this->getItem('browscap.releaseDate', false, $success); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  |             } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 $this->logger->error(new \InvalidArgumentException('an error occured while reading the data release date from the cache', 0, $e)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 1 |  |                 $releaseDate = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  |             if ($releaseDate !== null && $success) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 $this->releaseDate = $releaseDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         return $this->releaseDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * Gets the type of the Browscap data | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |     public function getType() : ?string | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |         if ($this->type === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |             $success = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 119 | 3 |  |             try { | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |                 $type = $this->getItem('browscap.type', false, $success); | 
            
                                                                        
                            
            
                                    
            
            
                | 121 | 3 |  |             } catch (InvalidArgumentException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |                 $this->logger->error(new \InvalidArgumentException('an error occured while reading the data type from the cache', 0, $e)); | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |                 $type = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 125 | 3 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 126 | 3 |  |             if ($type !== null && $success) { | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |                 $this->type = $type; | 
            
                                                                        
                            
            
                                    
            
            
                | 128 | 3 |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 131 | 3 |  |         return $this->type; | 
            
                                                                        
                            
            
                                    
            
            
                | 132 | 3 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 3 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * Get an item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @param string $cacheId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @param bool   $withVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @param bool   &$success | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 3 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      * @return mixed Data on success, null on failure | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @throws \Psr\SimpleCache\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     public function getItem(string $cacheId, bool $withVersion = true, ?bool &$success = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 3 |  |         if ($withVersion) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $cacheId .= '.' . $this->getVersion(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         if (! $this->cache->has($cacheId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             $success = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         $data = $this->cache->get($cacheId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         if (! is_array($data) || ! array_key_exists('content', $data)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $success = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 3 |  |         $success = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         return unserialize($data['content']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 3 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * save the content into an php file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 3 |  |      * @param string $cacheId     The cache id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * @param mixed  $content     The content to store | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @param bool   $withVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * @return bool whether the file was correctly written to the disk | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * @throws \Psr\SimpleCache\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     public function setItem(string $cacheId, $content, bool $withVersion = true) : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         // Get the whole PHP code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $data = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             'content' => serialize($content), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         if ($withVersion) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             $cacheId .= '.' . $this->getVersion(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         // Save and return | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         return $this->cache->set($cacheId, $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * Test if an item exists. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      * @param string $cacheId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * @param bool   $withVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      * @throws \Psr\SimpleCache\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     public function hasItem(string $cacheId, bool $withVersion = true) : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         if ($withVersion) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             $cacheId .= '.' . $this->getVersion(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         return $this->cache->has($cacheId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * Remove an item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @param string $cacheId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * @param bool   $withVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      * @throws \Psr\SimpleCache\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     public function removeItem(string $cacheId, bool $withVersion = true) : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         if ($withVersion) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             $cacheId .= '.' . $this->getVersion(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         return $this->cache->delete($cacheId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * Flush the whole storage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     public function flush() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         return $this->cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 240 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 241 |  |  |  |