commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
CacheValidator.php
1 <?php
2 
3 declare(strict_types=1);
10 namespace Commercetools\Client;
11 
12 use Psr\Cache\CacheItemPoolInterface;
13 use Psr\SimpleCache\CacheInterface;
14 use Symfony\Component\Cache\Adapter\FilesystemAdapter;
15 
16 final class CacheValidator
17 {
22  public static function validateCache($cache = null)
23  {
24  if ($cache instanceof CacheItemPoolInterface || $cache instanceof CacheInterface) {
25  return $cache;
26  }
27 
28  if (class_exists('Symfony\Component\Cache\Simple\FilesystemCache')) {
31  $cache = new \Symfony\Component\Cache\Simple\FilesystemCache('', 0, getcwd() . "/cache");
32  } else {
35  $cache = new FilesystemAdapter('', 0, getcwd() . "/cache");
36  }
37 
38  return $cache;
39  }
40 }