vendor/openpayu/openpayu/lib/OpenPayU/Oauth/Cache/OauthCacheFile.php line 18

Open in your IDE?
  1. <?php
  2. class OauthCacheFile implements OauthCacheInterface
  3. {
  4.     private $directory;
  5.     /**
  6.      * @param string $directory
  7.      * @throws OpenPayU_Exception_Configuration
  8.      */
  9.     public function __construct($directory null)
  10.     {
  11.         if ($directory === null) {
  12.             $directory dirname(__FILE__).'/../../../Cache';
  13.         }
  14.         if (!is_dir($directory) || !is_writable($directory)) {
  15.             throw new OpenPayU_Exception_Configuration('Cache directory [' $directory '] not exist or not writable.');
  16.         }
  17.         $this->directory $directory . (substr($directory, -1) != '/' '/' '');
  18.     }
  19.     public function get($key)
  20.     {
  21.         $cache = @file_get_contents($this->directory md5($key));
  22.         return $cache === false null unserialize($cache);
  23.     }
  24.     public function set($key$value)
  25.     {
  26.         return @file_put_contents($this->directory md5($key), serialize($value));
  27.     }
  28.     public function invalidate($key)
  29.     {
  30.         return @unlink($this->directory md5($key));
  31.     }
  32. }