commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CacheValidator.php
1<?php
2
3declare(strict_types=1);
10namespace Commercetools\Client;
11
12use Psr\Cache\CacheItemPoolInterface;
13use Psr\SimpleCache\CacheInterface;
14use Symfony\Component\Cache\Adapter\FilesystemAdapter;
15
16final 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}