-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathPsr16Adapter.php
More file actions
31 lines (25 loc) · 836 Bytes
/
Psr16Adapter.php
File metadata and controls
31 lines (25 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
declare(strict_types=1);
namespace Osteel\OpenApi\Testing\Cache;
use InvalidArgumentException;
use Psr\Cache\CacheItemPoolInterface;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Adapter\Psr16Adapter as CacheAdapter;
final class Psr16Adapter implements CacheAdapterInterface
{
/**
* Convert a PSR-16 caching library to a PSR-6 caching library.
*
* @param object $cache the caching library to convert
*/
public function convert(object $cache): CacheItemPoolInterface
{
if ($cache instanceof CacheItemPoolInterface) {
return $cache;
}
if ($cache instanceof CacheInterface) {
return new CacheAdapter($cache);
}
throw new InvalidArgumentException(sprintf('Unsupported %s object received', $cache::class));
}
}